Class: ErrorManager

ErrorManager()

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

Constructor

new ErrorManager()

Source:

Members

abortedText

Text used in place of statusText for aborted errors.
Source:

errorCacheSizeMax

Properties:
Name Type Description
Total Number amount of errors to keep
Source:

scopeSaveText

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

Methods

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:

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:

checkCacheSize()

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

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

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

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

getAllErrors() → {Array.<Object>}

Returns a copy of all errors.
Source:
Returns:
Array of error objects.
Type
Array.<Object>

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

onErrorAdd()

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

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:

save()

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

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