C_CPE_2409 · Question #53
A CRUD operation violated the foreign key constraints. Why should you register an error handler in your service implementation for the exception of the CAP SDK for Node.js?
The correct answer is D. To provide a meaningful error message. Registering an error handler in your CAP SDK service implementation lets you intercept the raw database exception and transform it into a clear, user-friendly message - for example, replacing a cryptic foreign key violation string with something like "The referenced entity does…
Question
A CRUD operation violated the foreign key constraints. Why should you register an error handler in your service implementation for the exception of the CAP SDK for Node.js?
Options
- ATo force the execution of the CRUD operation
- BTo ensure that the end user receives a message
- CTo avoid a break in the app execution
- DTo provide a meaningful error message
How the community answered
(22 responses)- A9% (2)
- B5% (1)
- C5% (1)
- D82% (18)
Explanation
Registering an error handler in your CAP SDK service implementation lets you intercept the raw database exception and transform it into a clear, user-friendly message - for example, replacing a cryptic foreign key violation string with something like "The referenced entity does not exist." Without this handler, the CAP framework may propagate the low-level database error text directly to the client, which is confusing and potentially exposes implementation details.
Why the distractors are wrong:
- A (force execution): An error handler handles the failure after it occurs - it cannot and should not bypass database constraints or retry the operation.
- B (ensure the user receives a message): The CAP framework already returns some error response to the client automatically; the handler's value is in making that message meaningful, not merely ensuring one exists.
- C (avoid breaking app execution): CAP's built-in error handling already prevents an unhandled exception from crashing the server - you're not registering the handler to keep the app alive.
Memory tip: Think of an error handler as a translator, not a safety net. The app won't crash without it, and the user will still get a response - but only the handler turns a database-level error into a human-readable one. When you see "meaningful error message," that's your keyword for option D.
Topics
Community Discussion
No community discussion yet for this question.