-
Notifications
You must be signed in to change notification settings - Fork 164
Open
Description
the $.i18n().load method returns a jquery promise.
| function jsonMessageLoader( url ) { |
HOWEVER, if the load fails, the promise does not fail. The code explicitly traps the fail callback and converts it to a success callback. It appears that this is to handle 404 exceptions properly via fallbacks. But this also then does not catch other exceptions, such as invalid JSON.
It seems like it would be better to resolve only on the 404 exception, and reject on other exceptions.
I am happy to submit a PR if that would be welcomed.
function jsonMessageLoader( url ) {
var deferred = $.Deferred();
$.getJSON( url )
.done( deferred.resolve )
.fail( function ( jqxhr, settings, exception ) {
$.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
// Ignore 404 exception, because we are handling fallabacks explicitly
deferred.resolve();
} );
return deferred.promise();
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels