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
- code
- errorValue
- SC.Error.HAS_MULTIPLE_VALUES
- isError
- label
- message
- Fields borrowed from SC.Object:
- concatenatedProperties, isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
Instance Methods
Field Detail
code NumberThe value the error represents. This is used when wrapping a value inside of an error to represent the validation failure.
Human readable description of the error. This can also be a non-localized key.
Instance Method Detail
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.