Error handling

Error handling — Decoding cairo's status

Synopsis




enum        cairo_status_t;
const char* cairo_status_to_string          (cairo_status_t status);
void        cairo_debug_reset_static_data   (void);

Description

Details

enum cairo_status_t

typedef enum _cairo_status {
    CAIRO_STATUS_SUCCESS = 0,
    CAIRO_STATUS_NO_MEMORY,
    CAIRO_STATUS_INVALID_RESTORE,
    CAIRO_STATUS_INVALID_POP_GROUP,
    CAIRO_STATUS_NO_CURRENT_POINT,
    CAIRO_STATUS_INVALID_MATRIX,
    CAIRO_STATUS_INVALID_STATUS,
    CAIRO_STATUS_NULL_POINTER,
    CAIRO_STATUS_INVALID_STRING,
    CAIRO_STATUS_INVALID_PATH_DATA,
    CAIRO_STATUS_READ_ERROR,
    CAIRO_STATUS_WRITE_ERROR,
    CAIRO_STATUS_SURFACE_FINISHED,
    CAIRO_STATUS_SURFACE_TYPE_MISMATCH,
    CAIRO_STATUS_PATTERN_TYPE_MISMATCH,
    CAIRO_STATUS_INVALID_CONTENT,
    CAIRO_STATUS_INVALID_FORMAT,
    CAIRO_STATUS_INVALID_VISUAL,
    CAIRO_STATUS_FILE_NOT_FOUND,
    CAIRO_STATUS_INVALID_DASH,
    CAIRO_STATUS_INVALID_DSC_COMMENT
} cairo_status_t;

cairo_status_t is used to indicate errors that can occur when using Cairo. In some cases it is returned directly by functions. but when using cairo_t, the last error, if any, is stored in the context and can be retrieved with cairo_status().

CAIRO_STATUS_SUCCESS no error has occurred
CAIRO_STATUS_NO_MEMORY out of memory
CAIRO_STATUS_INVALID_RESTORE cairo_restore without matching cairo_save
CAIRO_STATUS_INVALID_POP_GROUP no saved group to pop
CAIRO_STATUS_NO_CURRENT_POINT no current point defined
CAIRO_STATUS_INVALID_MATRIX invalid matrix (not invertible)
CAIRO_STATUS_INVALID_STATUS invalid value for an input cairo_status_t
CAIRO_STATUS_NULL_POINTER NULL pointer
CAIRO_STATUS_INVALID_STRING input string not valid UTF-8
CAIRO_STATUS_INVALID_PATH_DATA input path data not valid
CAIRO_STATUS_READ_ERROR error while reading from input stream
CAIRO_STATUS_WRITE_ERROR error while writing to output stream
CAIRO_STATUS_SURFACE_FINISHED target surface has been finished
CAIRO_STATUS_SURFACE_TYPE_MISMATCH the surface type is not appropriate for the operation
CAIRO_STATUS_PATTERN_TYPE_MISMATCH the pattern type is not appropriate for the operation
CAIRO_STATUS_INVALID_CONTENT invalid value for an input cairo_content_t
CAIRO_STATUS_INVALID_FORMAT invalid value for an input cairo_format_t
CAIRO_STATUS_INVALID_VISUAL invalid value for an input Visual*
CAIRO_STATUS_FILE_NOT_FOUND file not found
CAIRO_STATUS_INVALID_DASH invalid value for a dash setting
CAIRO_STATUS_INVALID_DSC_COMMENT invalid value for a DSC comment (Since 1.2)

cairo_status_to_string ()

const char* cairo_status_to_string          (cairo_status_t status);

cairo_debug_reset_static_data ()

void        cairo_debug_reset_static_data   (void);