# angular.service.$xhr.error

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

## Description

Error handler for `$xhr service`. An application can replaces this service with one specific for the application. The default implementation logs the error to `$log.error`.

## Dependencies

- `$log`

## Usage

    error(request, response);

### Parameters

- `request – {Object} –`

  Request object.

  The object has the following properties

  - `method` â `{string}` â The http request method.
  - `url` â `{string}` â The request destination.
  - `data` â `{(string|Object)=} â An optional request body.
  - `callback` â `{function()}` â The callback function
- `response – {Object} –`

  Response object.

  The response object has the following properties:

  - status â {number} â Http status code.
  - body â {string|Object} â Body of the response.

## Example

      fetch a non-existent file and log an error in the console:
      <button ng:click="$service('$xhr')('GET', '/DOESNT_EXIST')">fetch</button>