Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
feat(partial loader): add error response to errorHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven authored and knalli committed Sep 5, 2016
1 parent 233f30c commit e3aba1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/content/guide/en/12_asynchronous-loading.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ There are a few things you have to know before you'll be able to create your fir
error handler:

1) The partial loader expects the error handler to have the following signature
`function (part:String, langKey:String):Promise`
`function (part:String, langKey:String, response: Response):Promise`
2) You have to either resolve the promise with a translation table for the given
part and language or reject it
3) The partial loader will use the given translation table like it was successfully
Expand All @@ -288,7 +288,7 @@ Here is an example of a simple error handler:
```js
angular.module('translation')
.factory('MyErrorHandler', function ($q, $log) {
return function (part, lang) {
return function (part, lang, response) {
$log.error('The "' + part + '/' + lang + '" part was not loaded.');
return $q.when({});
};
Expand Down
4 changes: 2 additions & 2 deletions src/service/loader-partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ function $translatePartialLoader() {
.then(function(result){
self.tables[lang] = result.data;
return result.data;
}, function() {
}, function(response) {
if (errorHandler) {
return errorHandler(self.name, lang)
return errorHandler(self.name, lang, response)
.then(function(data) {
self.tables[lang] = data;
return data;
Expand Down

0 comments on commit e3aba1c

Please sign in to comment.