back to Overview

promise.error()

Registers a callback that will be called when the operation failed.
Available in all modules.

Syntax

promise.error(callback)

Parameters

callback
a function to be called when the operation has failed. The exact arguments depend on the operation. If the function returns a Promise, that Promise will be evaluated to determine the state of the returned Promise. If it returns regularly, the returned Promise will have success status. If it throws an error, the returned Promise will be in error state.
(return value)
a new Promise object. Its state is determined by the callback.

Description

Registers a callback that will be called when the operation failed. This is a convenience function that will invoke then() with only the second argument set. It shares all of its semantics.

Example

Simple handler for a HTTP request.

$.request('get', '/weather.html')
    .error(function() {
       alert('Got error!');
    });

Comments

comments powered by Disqus

back to Overview

Functions