{"ref":"capability:error-handling","page":"/capabilities/error-handling","json":"/capabilities/error-handling.json","generated":"2026-10-26","drafted_with_ai":true,"entity":{"id":"error-handling","name":"Error handling","domain":"protocols-and-apis","ecosystems":["cap","abap"],"universal":true,"description":"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.","short":"Turning a failure into a response a client can act on","core_coverage":{"state":"core-and-community","assessed_at":"2026-09-20","what_core_does":"On Node.js, [@sap/cds](artifact:sap-cds) gives a handler `req.reject`, which throws, and `req.error`, which records into `req.errors`; after each phase the framework rejects the request with one aggregate error, and the protocol adapters render it per protocol with status, code, localised message and target. On Java, [com.sap.cds:cds-services-bom](artifact:cap-java-cds-services-bom) ships `ServiceException`, which aborts the event with a mapped HTTP status, the Messages API, which collects messages without aborting, and an `ERROR_RESPONSE` event whose handlers can change the response.","where_it_stops":"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](capability:logging) line and telling a person about them, which is [notifications](capability:notifications), are left to a plugin or the application's own code.","sources":[{"url":"https://cap.cloud.sap/docs/node.js/events#req-error","title":"Events and requests — req.error / req.reject","checked":"2026-09-20","quote":"After each phase of request processing, that is, before / on / after, the framework checks whether errors got recorded in req.errors."},{"url":"https://cap.cloud.sap/docs/node.js/events#error-responses","title":"Events and requests — Error Responses","checked":"2026-09-20","quote":"To ensure that, all errors with a 5xx status code are returned to the client with only the respective generic message (example: 500 Internal Server Error)."},{"url":"https://cap.cloud.sap/docs/node.js/best-practices#error-handling","title":"Best Practices — Error Handling","checked":"2026-09-20","quote":"Make sure that unexpected errors are correctly logged. Do not catch errors you can't handle."},{"url":"https://cap.cloud.sap/docs/java/event-handlers/indicating-errors","title":"Indicating Errors","checked":"2026-09-20","quote":"The OData adapters turn all exceptions into an OData error response to indicate the error to the client."}],"relationship":"unassessed"},"history":[{"date":"2026-08-31","field":"core_coverage.state","from":"core","to":"core-only","reason":"States renamed to describe who is present rather than to interpret intent. left-open-on-purpose asserted a motive; core-and-community states a fact, with relationship carrying the intent separately."},{"date":"2026-09-14","field":"ecosystems","from":"cap","to":"cap, abap","reason":"Widened to ABAP: dominikpanzer/RESULT-for-ABAP and furkancosgun/EITHER-FOR-ABAP return failures as values, SchwarzIT/sap-usi-exception converts exception texts into BAPIRET2 and SYMSG, and abapify/throw raises an exception from a text or a system message."},{"date":"2026-09-20","field":"core_coverage.state","from":"core-only","to":"core-and-community","reason":"[cds-error-outbox](artifact:cds-error-outbox), an independent cds-plugin first seen on 2026-09-07, carries a provides edge to this capability on the CAP door, so SAP-official and independent providers are both present there. The previous state was assessed on 2026-08-31, before that entry. The relationship is unassessed: no retrieved document gives a history between the plugin and the runtimes."},{"date":"2026-10-26","field":"coverage_by_ecosystem.abap.community_adds","from":"","to":"Libraries that return a failure as a value or convert exception texts into BAPIRET2 and SYMSG; a process framework that collects errors as messages and resumes a failed object on its step.","reason":"Reassessed against the graph (check:capabilities): brandeis-consulting-abap-prc arrived after the block was last looked at, and the block named no community kinds."}],"coverage_by_ecosystem":{"abap":{"state":"core-and-community","assessed_at":"2026-09-14","what_core_does":"Class-based exceptions: an exception is an instance of an exception class, raised with RAISE EXCEPTION or THROW in a conditional expression, and handled in the CATCH blocks of a TRY structure.","where_it_stops":"At raising and catching. The language has no result value for an expected failure, and converting exception texts into BAPIRET2 or SYMSG for a caller is left to the application.","sources":[{"url":"https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenexceptions.htm","title":"ABAP Keyword Documentation — Class-Based Exceptions","checked":"2026-09-14","quote":"A class-based exception can be handled in a TRY control structure."}],"community_adds":"Libraries that return a failure as a value, such as [RESULT-for-ABAP](artifact:dominikpanzer-result-for-abap), and that convert exception texts into BAPIRET2 and SYMSG, such as [sap-usi-exception](artifact:schwarzit-sap-usi-exception). [ABAP-PRC](artifact:brandeis-consulting-abap-prc) is a process framework that collects errors as messages and resumes a failed object on the step that failed.","relationship":"unassessed"}},"framing_by_ecosystem":{"abap":{"description":"In ABAP the question is how a failure travels back to the caller: as a class-based exception, as a returned result object that carries the error, or as a message table such as BAPIRET2."}},"drafted_with_ai":true},"sap_delivery":{"door":"cap","all":{"built_in":[{"ref":"artifact:sap-cds","name":"@sap/cds","json":"/artifacts/sap-cds.json"},{"ref":"artifact:cap-java-cds-services-bom","name":"com.sap.cds:cds-services-bom","json":"/artifacts/cap-java-cds-services-bom.json"}],"documented_pattern":[],"announced":[],"packages":[]},"by_flavor":{"node":{"built_in":[{"ref":"artifact:sap-cds","name":"@sap/cds","json":"/artifacts/sap-cds.json"}],"documented_pattern":[],"announced":[],"packages":[]},"java":{"built_in":[{"ref":"artifact:cap-java-cds-services-bom","name":"com.sap.cds:cds-services-bom","json":"/artifacts/cap-java-cds-services-bom.json"}],"documented_pattern":[],"announced":[],"packages":[]}}},"edges":{"use_cases":[],"shared_tasks":[],"related_tasks":[],"options":[{"ref":"artifact:sap-cds","name":"@sap/cds","json":"/artifacts/sap-cds.json","ecosystem":"cap","origin_ring":"sap-official"},{"ref":"artifact:brandeis-consulting-abap-prc","name":"ABAP-PRC","json":"/artifacts/brandeis-consulting-abap-prc.json","ecosystem":"abap","origin_ring":"independent"},{"ref":"artifact:cds-error-outbox","name":"cds-error-outbox","json":"/artifacts/cds-error-outbox.json","ecosystem":"cap","origin_ring":"independent"},{"ref":"artifact:cap-java-cds-services-bom","name":"com.sap.cds:cds-services-bom","json":"/artifacts/cap-java-cds-services-bom.json","ecosystem":"cap","origin_ring":"sap-official"},{"ref":"artifact:furkancosgun-either-for-abap","name":"EITHER-FOR-ABAP","json":"/artifacts/furkancosgun-either-for-abap.json","ecosystem":"abap","origin_ring":"independent"},{"ref":"artifact:dominikpanzer-result-for-abap","name":"RESULT-for-ABAP","json":"/artifacts/dominikpanzer-result-for-abap.json","ecosystem":"abap","origin_ring":"independent"},{"ref":"artifact:schwarzit-sap-usi-exception","name":"sap-usi-exception","json":"/artifacts/schwarzit-sap-usi-exception.json","ecosystem":"abap","origin_ring":"independent"},{"ref":"artifact:abapify-throw","name":"throw","json":"/artifacts/abapify-throw.json","ecosystem":"abap","origin_ring":"independent"}],"samples":[{"ref":"artifact:miyasuta-cap-java-snippets","name":"cap-java-snippets","json":"/artifacts/miyasuta-cap-java-snippets.json"}],"explained_by":[{"ref":"content:devtoberfest-2026-errors-in-bapis-or-rap-bos","name":"S/4HANA Custom Development - What happens in case of errors in BAPIs or RAP BOs?","json":"/content/devtoberfest-2026-errors-in-bapis-or-rap-bos.json"},{"ref":"content:building-a-real-time-currency-conversion-iflow-using-sap-cloud-integration-cpi","name":"Building a Real‑Time Currency Conversion iFlow using SAP Cloud Integration (CPI)","json":"/content/building-a-real-time-currency-conversion-iflow-using-sap-cloud-integration-cpi.json"},{"ref":"content:connecting-sap-integration-suite-with-slack-a-hands-on-guide-with-open-connector","name":"Connecting SAP Integration Suite with Slack: A Hands‑On Guide with Open Connectors","json":"/content/connecting-sap-integration-suite-with-slack-a-hands-on-guide-with-open-connector.json"},{"ref":"content:how-to-create-a-purchase-order-through-bapi-in-the-sap-through-program-se38-t-co","name":"How to create a Purchase Order through BAPI in the SAP through program ( SE38 ) T-CODE .","json":"/content/how-to-create-a-purchase-order-through-bapi-in-the-sap-through-program-se38-t-co.json"},{"ref":"content:parallel-data-filtering-and-dropbox-integration-using-sap-cloud-integration","name":"Parallel Data Filtering and Dropbox Integration Using SAP Cloud Integration","json":"/content/parallel-data-filtering-and-dropbox-integration-using-sap-cloud-integration.json"},{"ref":"content:new-tutorial-for-ui5-middleware-fe-mockserver","name":"New tutorial for UI5 Middleware FE Mockserver","json":"/content/new-tutorial-for-ui5-middleware-fe-mockserver.json"},{"ref":"content:basic-code-s-of-abap","name":"Basic code's of ABAP","json":"/content/basic-code-s-of-abap.json"},{"ref":"content:migration-journey-from-mulesoft-to-sap-integration-suite-ci","name":"Migration Journey from MuleSoft to SAP Integration Suite (CI)","json":"/content/migration-journey-from-mulesoft-to-sap-integration-suite-ci.json"},{"ref":"content:effective-axios-error-logging-for-robust-sap-integrations","name":"Effective Axios Error Logging for Robust SAP Integrations","json":"/content/effective-axios-error-logging-for-robust-sap-integrations.json"},{"ref":"content:how-to-subscribe-or-fetch-data-from-solace-to-cpi-using-aem-adapter-part-5","name":"How to subscribe or fetch data from solace to CPI using AEM Adapter : part-5","json":"/content/how-to-subscribe-or-fetch-data-from-solace-to-cpi-using-aem-adapter-part-5.json"},{"ref":"content:beginners-guide-to-advanced-event-mesh","name":"Beginners Guide to Advanced Event Mesh","json":"/content/beginners-guide-to-advanced-event-mesh.json"},{"ref":"content:making-the-case-for-enhanced-rest-adapter-in-sap-integration-suite","name":"Making the Case for Enhanced REST Adapter in SAP Integration Suite","json":"/content/making-the-case-for-enhanced-rest-adapter-in-sap-integration-suite.json"},{"ref":"content:sap-email-functionality-in-sap-with-a-custom-function-module","name":"SAP: Email Functionality in SAP with a Custom Function Module","json":"/content/sap-email-functionality-in-sap-with-a-custom-function-module.json"},{"ref":"content:don-t-let-it-crash-is-this-the-new-cap-guideline","name":"Don't \"let it crash\", is this the new CAP guideline?","json":"/content/don-t-let-it-crash-is-this-the-new-cap-guideline.json"},{"ref":"content:messaging-system-for-odata-error-warning-and-information-messages","name":"Messaging System for Transferring Error, Warning, and Information Messages from OData V4 Services to HTTP Client Applications","json":"/content/messaging-system-for-odata-error-warning-and-information-messages.json"},{"ref":"content:sap-cloud-application-programming-model-cap-part-2","name":"SAP Cloud Application Programming Model（CAP）：カスタムロジックの実装 – Part 2","json":"/content/sap-cloud-application-programming-model-cap-part-2.json"}],"normative_context":[]}}