HandleAPIError handles remote server errors. Optionally, use it when you write your server's HTTP clients using the the /x/client package. When the HTTP Client sends data to a remote server but that remote server failed to accept the request as expected, then the error will be proxied to this server
(ctx *context.Context, err error)
| 380 | // HTTP internal server error to the end-client and |
| 381 | // prints the "err" using the "LogError" package-level function. |
| 382 | func HandleAPIError(ctx *context.Context, err error) { |
| 383 | // Error expected and came from the external server, |
| 384 | // save its body so we can forward it to the end-client. |
| 385 | if apiErr, ok := client.GetError(err); ok { |
| 386 | handleAPIError(ctx, apiErr) |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | Internal.LogErr(ctx, err) |
| 391 | } |
| 392 | |
| 393 | func handleAPIError(ctx *context.Context, apiErr client.APIError) { |
| 394 | // Error expected and came from the external server, |
nothing calls this directly
no test coverage detected
searching dependent graphs…