Skip to main content
Version: 0.12

status

The Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.

IMPORTANT: Backward compatibility notes:

To ensure any pair of senders and receivers continues to correctly signal and interpret erroneous situations, the senders and receivers MUST follow these rules:

  1. Old senders and receivers that are not aware of code field will continue using the deprecated_code field to signal and interpret erroneous situation.

  2. New senders, which are aware of the code field MUST set both the deprecated_code and code fields according to the following rules:

    if code==STATUS_CODE_UNSET then deprecated_code MUST be set to DEPRECATED_STATUS_CODE_OK.

    if code==STATUS_CODE_OK then deprecated_code MUST be set to DEPRECATED_STATUS_CODE_OK.

    if code==STATUS_CODE_ERROR then deprecated_code MUST be set to DEPRECATED_STATUS_CODE_UNKNOWN_ERROR.

These rules allow old receivers to correctly interpret data received from new senders.

  1. New receivers MUST look at both the code and deprecated_code fields in order to interpret the overall status:

    If code==STATUS_CODE_UNSET then the value of deprecated_code is the carrier of the overall status according to these rules:

    if deprecated_code==DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret
    the overall status to be STATUS_CODE_UNSET.

    if deprecated_code!=DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret
    the overall status to be STATUS_CODE_ERROR.

    If code!=STATUS_CODE_UNSET then the value of deprecated_code MUST be ignored, the code field is the sole carrier of the status.

These rules allow new receivers to correctly interpret data received from old senders.

Functions

error(message)

Returns an error status code, with user defined error messsage

ok()

Returns a success status code