Error response handling

Describes how errors should be handled.

On error the HTTP status code is set in the response.
At least the following status codes should be handled: 400, 404, 422, 500, 502 .

All endpoints use a generic response format.

status is always “error”
code is an integer value equal to the http status code
message is a string with a meaningful error message

Response:

{
 "status": "error",
 "code": <http error code(integer)>,
 "message": <String>
}

Example (Not Found)

Request:

curl http://localhost/api/bmc/1.0/0/error_msg

Response:

{
 "status": "error",
 "code": 404,
 "message": "Not Found"
}

Example (Unprocessable Entity)

Request:

curl http://localhost/api/bmc/1.0/0/buzzer --header "Content-Type: application/json" --request POST --data '{"mode": 4, "duration": 0}'

Response:

{
 "status": "error",
 "code": 422,
 "message": "duration out of range"
}