[]previous and next page

ServerFnError (@shadow-js/dusk/client)

The server failed to run the function and told the client no more than the status: an unexpected error on the server (anything that is not an HttpError), a method the function does not accept, or an aborted request.

The server failed to run the function and told the client no more than the status: an unexpected error on the server (anything that is not an HttpError), a method the function does not accept, or an aborted request. The message is the public text (the reason phrase in production); details and the stack stay in the server's log (look for requestId there). An HttpError the function threw is not a ServerFnError: it arrives as an HttpError with the same status.

Import#

ts
import { ServerFnError } from "@shadow-js/dusk/client";

Signature#

ts
class ServerFnError extends Error

Members#

Name Type Description
status readonly status: number The HTTP status of the answer.
requestId readonly requestId: string | undefined Id of the request on the server, for the server log.

Examples#

ts
try { await saveTodo(todo); } catch (error) {
  if (error instanceof ServerFnError) console.warn(error.status, error.requestId);
}