mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-24 18:30:23 +00:00
- split up services into files under src/service - split up specs into files under test/service - rewrite all specs so that they don't depend on one global forEach - get rid of obsolete code and tests in ng:switch - rename mock $log spec from "$log" to "$log mock"
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
/**
|
||
* @workInProgress
|
||
* @ngdoc service
|
||
* @name angular.service.$xhr.error
|
||
* @function
|
||
* @requires $log
|
||
*
|
||
* @description
|
||
* Error handler for {@link angular.service.$xhr $xhr service}. An application can replaces this
|
||
* service with one specific for the application. The default implementation logs the error to
|
||
* {@link angular.service.$log $log.error}.
|
||
*
|
||
* @param {Object} request 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
|
||
*
|
||
* @param {Object} response Response object.
|
||
*
|
||
* The response object has the following properties:
|
||
*
|
||
* - status – {number} – Http status code.
|
||
* - body – {string|Object} – Body of the response.
|
||
*
|
||
* @example
|
||
<doc:example>
|
||
<doc:source>
|
||
fetch a non-existent file and log an error in the console:
|
||
<button ng:click="$service('$xhr')('GET', '/DOESNT_EXIST')">fetch</button>
|
||
</doc:source>
|
||
</doc:example>
|
||
*/
|
||
angularServiceInject('$xhr.error', function($log){
|
||
return function(request, response){
|
||
$log.error('ERROR: XHR: ' + request.url, request, response);
|
||
};
|
||
}, ['$log']);
|