You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: java/event-handlers/indicating-errors.md
+3-19Lines changed: 3 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -128,26 +128,10 @@ CAP Java provides out-of-the-box translation for error messages that originate f
128
128
The error messages are optimized for UI scenarios and avoid any technical references to entity names or element names. Message targets are used where appropriate to allow the UI to show the error message next to the affected UI element.
129
129
You can enable these translated error messages by setting [<Configjava>cds.errors.defaultTranslations.enabled: true</Config>](../developing-applications/properties#cds-errors-defaultTranslations-enabled).
130
130
131
-
### Exporting the Default Messages
132
-
133
-
As of CAP Java 1.10.0, you can extract the available default messages as a resource bundle file for further processing (for example, translation). Therefore, the delivery artifact [cds-services-utils](https://search.maven.org/artifact/com.sap.cds/cds-services-utils) contains a resource bundle `cds-messages-template.properties` with all available error codes and default messages. Application developers can use this template to customize error messages thrown by the CAP Java SDK in the application.
134
-
135
-
1.[Download](https://search.maven.org/artifact/com.sap.cds/cds-services-utils) the artifact or get it from the local Maven repository in `~/.m2/repository/com/sap/cds/cds-services-utils/<VERSION>/cds-services-utils-<VERSION>.jar`.
136
-
1. Extract the file.
137
-
```sh
138
-
jar -f cds-services-utils-<VERSION>.jar -x cds-messages-template.properties
139
-
```
140
-
::: tip
141
-
\<VERSION> is the version of CAP Java you're using in your project.
142
-
:::
143
-
144
-
1. Rename the extracted file `cds-messages-template.properties` appropriately (for example, to `cds-messages.properties`) and move it to the resource directory of your application.
145
-
1. In your Spring Boot application, you have to register this additional [resource bundle](https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.internationalization) accordingly.
146
-
147
-
> Now, you're able to customize the stack error messages in your application.
148
-
149
-
With new CAP Java versions, there could be also new or changed error messages in the stack. To identify these changes, export`cds-messages-template.properties` from the new CAP Java version and compare it with the previous version using a diff tool.
131
+
### Provide custom error messages
150
132
133
+
By default, CAP Java provides error messages in several languages. If an error message or translation isn't sufficient for an application, it can be overwritten with a custom error message. Applications can provide the new error message under the respective error code in the application's `messages.properties` resource bundle under `src/main/resources`.
134
+
To know which error codes and messages are available by default, you can have a look at the Java enumeration `com.sap.cds.services.utils.CdsErrorStatuses` with your favorite IDE. This enumeration shows all available error codes and messages that are used by the CAP Java runtime.
0 commit comments