WSError
Specifies a description of the status-code that is returned in the HTTP response.
Syntax
WSError= "description"
- description defines a short description as the
"Reason-Phrase"
for the status-code that is returned in the HTTP response message.
WSError
is an optional attribute.
Usage
You use this attribute in the management of application level errors in conjunction with WSThrows. When you use WSThrows
with the "code:@variable" option to return a description of
the status-code instead of the standard HTTP status code description, you must reference a variable
that has the WSError
attribute.
You must set the attribute on a public variable defined at the modular level. You can define it
as any Genero BDL simple or complex type depending on your requirements for the detail about the
error. For example, if defined as a RECORD
or ARRAY
, by default,
it will be serialized in JSON/XML
on the client side. If you define it as a simple
type, it will be serialized in TEXT/PLAIN
.
You code in your REST function to set the variable at runtime with a specific reason for the HTTP status code. The response is sent in a call to the com.WebServiceEngine.SetRestError method referencing the variable.
When the client stub is generated from the OpenAPI documentation of your Web service, the correct Genero BDL variable corresponding to the HTTP status code is deserialized on the client side.
Example WSError in record variable
PUBLIC DEFINE userError RECORD ATTRIBUTES(WSError = "User error")
message STRING
END RECORD
Example WSError in integer variable
PUBLIC DEFINE fatalError INTEGER ATTRIBUTES(WSError = "fatal error")