simbrief docs
Errors
types.APIError(Message,Code): SimBrief answered but the fetch failed.Messageis the OFP’s fetch status;Codeis the HTTP status, or 0 when the error came with a 200 reply.- Wrapped errors (
fmt.Errorfwith%w): transport and decoding failures, e.g. a timeout or a body that is not an OFP. A non-200 reply without a fetch status is a plain error with the status and body. - Sentinels from
FlightPlanRequest.Validate():types.ErrMissingOrigin,types.ErrMissingDestination,types.ErrMissingAircraft. (ErrMissingUserID,ErrInvalidUserIDandErrInvalidAPIKeyare declared but not returned by the library.) ValidateFlightPlanRequestreturns plainfmt.Errorfmessages.
_, err := c.GetFlightPlan(&types.FetchRequest{UserID: "123456", JSON: true})
var apiErr types.APIError
if errors.As(err, &apiErr) {
fmt.Println("SimBrief:", apiErr.Message, apiErr.Code) // fetch status text, HTTP status (0 on a 200)
}
err := types.NewFlightPlanRequest("LKPR", "", "A320").Validate()
if errors.Is(err, types.ErrMissingDestination) {
fmt.Println("destination missing")
}
Common problems
| Problem | Cause |
|---|---|
Fetch fails with types.APIError |
the message is SimBrief’s fetch status (unknown user, no plan generated yet) |
| Invalid aircraft code | list valid codes with GetAircraftTypes() |
Empty TLR |
the plan was generated without runway analysis, or the aircraft has no TLRData |