Error Handling
You can handle errors globally, or per route when you need custom behavior.
Global internal error handler
Section titled “Global internal error handler”app.setInternalErrorHandler((req, res, error) => { res.status(500).send({ source: 'global-handler', message: error.message, });});Route-specific handleError
Section titled “Route-specific handleError”import { Route } from 'owebjs';
export default class RouteWithCustomError extends Route { handle() { throw new Error('route-specific-error'); }
handleError(_req, res, err) { return res.status(409).send({ source: 'route-handleError', message: err.message, }); }}Use route-level handling when you want endpoint-specific status codes or payload shape.