Page History
...
Multiexcerpt | ||
---|---|---|
| ||
REST services in general return errors via the HTTP status code, so first of all, you should carefully choose the status code you are returning on a service call. Besides the HTTP status code there is no standard way of how to provide additional error information with REST service implementations. Developers can return additional information in HTTP headers or body, though. With the Bridge REST implementation, we decided to provide error information via the HTTP body by an error class or a Blob (Bridge 7.1.0). |
Multiexcerpt | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||
Default Error ClassEach REST port type should have a default <<RESTError>> class assigned. The Bridge will use this class as a default output in case of error. Figure: Example REST Error Class In case of error, this class should be
Refer to Implementing REST Operations for more information on error handling. Specific Error ClassesYou can define specific error classes for specific HTTP errors to provide more information on the error, or just return a Blob. Figure: Specific Error Class
There is no difference between using an error class or a Blob. Assign the specific error class to related operations or REST resources via a <<use>> dependency having stereotype <<RESTResponseDefinition>>. Figure: Assigning Error Class to REST Operations On these <<use>> dependencies, you have to specify an HTTP status code on the name tag. For this status code, the default error class will be overwritten by the specific class.
You can apply the following name templates:
The definitions above are reflected in the OpenAPI service description (see REST Response Definitions).
Bridge 7.1.0 For responses of type Blob, you can additionally specify a blob body content type on the <<RESTResponseDefinition>> (tag blobBodyContentType). This information will be generated to the OpenAPI descriptor file and will set the the "Content-Type" header to this content type. Default content type is "application/octet-stream". Refer to Implementing REST Operations for more information on error handling. |