Class: module:argos/ErrorManager

module:argos/ErrorManager()

ErrorManager is a singleton that parses and stores SData error responses into localStorage.

Constructor

new module:argos/ErrorManager()

Source:

Members

(static) abortedText

Text used in place of statusText for aborted errors.

Source:

(static) errorCacheSizeMax

Properties:
Name Type Description
Total Number

amount of errors to keep

Source:

(static) scopeSaveText

Text put in place of the scope property to prevent circular references.

Source:

Methods

(static) addError(serverResponse, requestOptions, viewOptions, failType)

Adds a custom error item by combining error message/options for easier tech support

Parameters:
Name Type Description
serverResponse Object

Full response from server, status, responsetext, etc.

requestOptions Object

GET or POST options sent, only records the URL at this time

viewOptions Object

The View Options of the view in which the error occurred

failType String

Either "failure" or "aborted" as each response has different properties

Source:

(static) addSimpleError(description, error)

Adds a custom error item and fires the onErrorAdd event

Parameters:
Name Type Description
description

Short title or description of the Error. Ex: Duplicate Found, Invalid Email

error

Object The error object that will be JSON-stringified and stored for use.

Source:

(static) checkCacheSize()

Ensures there is at least 1 open spot for a new error by checking against errorCacheSizeMax and removing old errors as needed

Source:

(static) extractAbortResponse(response) → {Object}

Abort error is hardset due to exceptions from reading properties FF 3.6: https://bugzilla.mozilla.org/show_bug.cgi?id=238559

Parameters:
Name Type Description
response Object

XMLHttpRequest object sent back from server

Source:
Returns:

Object with hardset abort info

Type
Object

(static) extractFailureResponse(response) → {Object}

Explicitly extract values due to how read-only objects are enforced

Parameters:
Name Type Description
response Object

XMLHttpRequest object sent back from server

Source:
Returns:

Object with only relevant, standard properties

Type
Object

(static) fromJsonArray(json) → {Object}

Attempts to parse a json string into a javascript object The need for this function is the fallback in case of failure

Parameters:
Name Type Description
json String

Json formatted string or array.

Source:
Returns:

Javascript object from json string.

Type
Object

(static) getAllErrors() → {Array.<Object>}

Returns a copy of all errors.

Source:
Returns:

Array of error objects.

Type
Array.<Object>

(static) getError(key, value) → {Object}

Retrieve a error item that has the specified key|value pair

Parameters:
Name Type Description
key String

Property of error item to check, such as errorDate or url

value Number/String

Value of the key to match against

Source:
Returns:

Returns the first error item in the match set or null if none found

Type
Object

(static) onErrorAdd()

Publishes the /app/refresh event to notify that an error has been added

Source:

(static) removeError(index, amount)

Removes the specified index from the error list.

Parameters:
Name Type Description
index Number

Index of error to remove.

amount Number

Number of errors to remove from indexed point, if not provided defaults to 1.

Source:

(static) save()

Attempts to save all errors into localStorage under the errorlog key.

Source:

(static) serializeValues(obj) → {Object}

Prepares an object for JSON serialization by recursively discarding non value keys

Parameters:
Name Type Description
obj Object

Object to be JSON serialized

Source:
Returns:

Cleaned object for for JSON serialization

Type
Object