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 SHIPS
Node.js →

@sap/cds Provides req.error and req.reject, and serialises the result into protocol-correct payloads with target paths.

Java →

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 logging line and telling a person about them, which is notifications, are left to a plugin or the application's own code.

THE COMMUNITY ADDS

Artifacts3

3 of 3 artifacts
ArtifactSignals
CDS plugins1
cds-error-outboxCaptures CAP service errors, deduplicates them and mails alerts
Signals
Functional boundary
Packages2
@sap/cdsCAP Node.js runtime
Signals
none
com.sap.cds:cds-services-bomMaven bill of materials pinning CAP Java module versions
Signals
none

Content5

Group by
Piece, what it offers
Effective Axios Error Logging for Robust SAP Integrations
SAP Community, Sahil2508, BlogThe reasoningA recipe
Beginners Guide to Advanced Event Mesh
SAP Community, PriyankaChak, Blog
Don't "let it crash", is this the new CAP guideline?
SAP Community, Dinu, Blog
Show 2 more
Messaging System for Transferring Error, Warning, and Information Messages from OData V4 Services to HTTP Client Applications
SAP Community, arley-triana-morin, BlogThe reasoningA recipeRunnable code
Core changed
SAP Cloud Application Programming Model(CAP):カスタムロジックの実装 – Part 2
SAP Community, rasai, part 2 of 2, Blog
Don't "let it crash", is this the new CAP guideline?
SAP Community, Dinu, Blog

Seen working1

ArtifactSignals
Samples1
cap-java-snippetsTen short CAP Java references, one document per topic
none

Details

Coverage
statecore and community, CAP
assessed
relationshipunassessed
also inABAP
SourceEvents and requests — req.error / req.rejectchecked SourceEvents and requests — Error Responseschecked SourceBest Practices — Error Handlingchecked SourceIndicating Errorschecked
For your agent
Ref
capability:error-handling
JSON
/capabilities/error-handling.json
MCP
Connecting an agent