Error handling
Turning a failure into a response a client can act on — protocol-correct error payloads, correlation, and a boundary between internal detail and what a caller sees.
Overview
@sap/cds Provides req.error and req.reject, and serialises the result into protocol-correct payloads with target paths.
com.sap.cds:cds-services-bom Ships ServiceException for aborting an event with a mapped HTTP status and the Messages API for collecting errors, warnings, info and success messages on a request without aborting it, both usable without an extra dependency.
Not covered: It stops at the response the client receives. On Node.js in production a 5xx error goes out as its generic message only, and capire's advice for an unexpected error is to make sure it is logged and not to keep the app running; keeping a record of failures beyond a loggingLoggingSeeing what a running service did, in a form something can read afterwards — levels, a formatter that suits a laptop and one that suits a log service.SAP only line and telling a person about them, which is notificationsNotificationsTelling a person something happened when they are not looking at the screen — a notification in the launchpad, an email, a message somewhere they already are.SAP and community, narrow by design, are left to a plugin or the application's own code.
Artifacts
Content
Show 2 more
Seen working
Details
Coverage
For your agent
- Ref
capability:error-handling- JSON
- /capabilities/error-handling.json
- MCP
- Connecting an agent