Skip to main content
Version: v0.14.0

Server2Client Communication

Magellan supports automatic response and error propagation from the server executed version of a @service annoted function to the client.

Data Structure

The following is the server response payload which will automatically be handled by magellan-client and provided to the @service functions promise.

ResponsePayload

  • data: function result. Used for the @service functions promise resolution.
  • error: Error object. Used for the @service functions promise rejection.

ResponseError

  • message: Non-technical error message naming failed function. Used as @service function promise reject reason.
  • error: Full error message including callstack from the server.
    • This field is only provided if NODE_ENV is not production.
    • This information will be written to console.error if present.

Important: The response received from the server always only includes the field data or error, but never both.

Flow

Response Examples

Success

{ "data": { "fibonacciValue": 8 } }

Error in production

{
"error": {
"message": "Function request to \"calculateFibonacci\" failed."
}
}

Error in development

{
"error": {
"message": "Function request to \"calculateFibonacci\" failed.",
"error": "at /app/src/services/fibonacci.ts:32:17\n . value is undefined"
}
}