Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkError.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* SkErrorCallbackFunction )(SkError, void *)
 Type for callback functions to be invoked whenever an error is registered. More...
 

Enumerations

enum  SkError {
  kNoError_SkError =0, kInvalidArgument_SkError, kInvalidOperation_SkError, kInvalidHandle_SkError,
  kInvalidPaint_SkError, kOutOfMemory_SkError, kParseError_SkError, kInternalError_SkError
}
 

Functions

SkError SkGetLastError ()
 Return the current per-thread error code. More...
 
void SkClearLastError ()
 Clear the current per-thread error code back to kNoError_SkError.
 
void SkSetErrorCallback (SkErrorCallbackFunction cb, void *context)
 Set the current per-thread error callback. More...
 
const char * SkGetLastErrorString ()
 Get a human-readable description of the last (per-thread) error that occurred. More...
 

Typedef Documentation

typedef void(* SkErrorCallbackFunction)(SkError, void *)

Type for callback functions to be invoked whenever an error is registered.

Callback functions take the error code being set, as well as a context argument that is provided when the callback is registered.

Enumeration Type Documentation

enum SkError
Enumerator
kNoError_SkError 

All is well.

kInvalidArgument_SkError 

User argument passed to Skia function was invalid: NULL when that’s not allowed, out of numeric range, bad enum, or violating some other general precondition.

kInvalidOperation_SkError 

User tried to perform some operation in a state when the operation was not legal, or the operands make no sense (e.g., asking for pixels from an SkPictureCanvas).

Other examples might be inset()’ing a rectangle to make it degenerate (negative width/height).

kInvalidHandle_SkError 

Probably not needed right now, but in the future we could have opaque handles for SkPictures floating around, and it would be a good idea to anticipate this kind of issue.

kInvalidPaint_SkError 

This is probably not possible because paint surely has defaults for everything, but perhaps a paint can get into a bad state somehow.

kOutOfMemory_SkError 

Skia was unable to allocate memory to perform some task.

kParseError_SkError 

Skia failed while trying to consume some external resource.

kInternalError_SkError 

Something went wrong internally; could be resource exhaustion but will often be a bug.

Function Documentation

SkError SkGetLastError ( )

Return the current per-thread error code.

Error codes are "sticky"; they are not not reset by subsequent successful operations.

const char* SkGetLastErrorString ( )

Get a human-readable description of the last (per-thread) error that occurred.

The returned error message will include not only a human readable version of the error code, but also information about the conditions that led to the error itself.

void SkSetErrorCallback ( SkErrorCallbackFunction  cb,
void *  context 
)

Set the current per-thread error callback.

Parameters
cbThe callback function to be invoked. Passing NULL for cb will revert to the default error callback which does nothing on release builds, but on debug builds will print an informative error message to the screen.
contextAn arbitrary pointer that will be passed to the provided callback function.