@intuitionrobotics/thunderstorm
Version:
21 lines • 1.22 kB
TypeScript
import { type Logger } from "@intuitionrobotics/ts-common";
import { ApiException } from "../../exceptions.js";
import { type HttpRequestData } from "./server-api.js";
/**
* The shared error-composition pipeline, extracted verbatim from
* `ServerApi.call()`'s catch block. BOTH the legacy `ServerApi` (its own
* internal catch) and the new app-level `terminalErrorHandler` route errors
* through this ONE function, so the two endpoint styles can never drift.
*
* It normalizes any thrown value to an `ApiException`, logs it, maps the
* response code to a `ServerErrorSeverity`, and — unless the exception opts
* out via `setDispatchError(false)` — composes an error message through the
* `Storm` instance and dispatches `dispatch_onServerError`.
*
* Returns the resolved `ApiException`; the CALLER decides how to write it
* (`response.serverError` for 500, `response.exception` otherwise). The
* `logger` lets callers attribute the logs to themselves (`ServerApi` passes
* `this`; the app-level handler passes its own module logger).
*/
export declare function composeApiError(err: any, requestData: HttpRequestData, logger: Logger): Promise<ApiException>;
//# sourceMappingURL=api-error.d.ts.map