Class: SC.Error


Extends SC.Object.

An error, used to represent an error state.

Many API's within SproutCore will return an instance of this object whenever they have an error occur. An error includes an error code, description, and optional human readable label that indicates the item that failed.

Depending on the error, other properties may also be added to the object to help you recover from the failure.

You can pass error objects to various UI elements to display the error in the interface. You can easily determine if the value returned by some API is an error or not using the helper SC.ok(value).

Faking Error Objects

You can actually make any object you want to be treated like an Error object by simply implementing two properties: isError and errorValue. If you set isError to YES, then calling SC.ok(obj) on your object will return NO. If isError is YES, then SC.val(obj) will return your errorValue property instead of the receiver.

When using SC.typeOf(obj), SC.T_ERROR will only be returned if the obj is an instance of SC.Error

Defined in: error.js

Since:
SproutCore 1.0

Field Summary

Instance Methods

Field Detail

code Number
error code. Used to designate the error type.
errorValue Object

The value the error represents. This is used when wrapping a value inside of an error to represent the validation failure.

SC.Error.HAS_MULTIPLE_VALUES Number
Standard error code for errors that do not support multiple values.
isError Boolean
Walk like a duck.
label String
Human readable name of the item with the error.
message String

Human readable description of the error. This can also be a non-localized key.

Instance Method Detail

errorObject()

The original error object. Normally this will return the receiver. However, sometimes another object will masquerade as an error; this gives you a way to get at the underlying error.

trace()
The error stacktrace.
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:20 GMT-0600 (CST)