Error Handling

GraceJS provides a structured way to handle errors that occur during route processing. You can define global error handlers that respond to errors consistently.

import { createGrace } from '@grace-js/grace';

const app = createGrace();

app.registerError(async (request, error) => {
  return {
    code: error.code || 500,
    body: { message: error.message || 'Internal Server Error' },
  };
});

Last updated