Someone (not me) has implemented a global ember error handler as a mixin that is used on all controllers:
export default Ember.Mixin.create({
handleErrors: function (error) {
alert(error);
}
});
import ErrorHandler from '../mixins/error-handler';
export default BaseController.extend(ErrorHandler , {
....
});
I'm making an ajax call and under certain circumstances I want it to fail (record is locked in the backend and user shouldn't be able to continue).
I'm return a HTTP error code to my ajax call:
return Ember.$.ajax({
url:url,
method:'GET',
cache:false,
xhrFields: {
withCredentials: true
}
})
.fail(( jqXHR) => {
if (jqXHR.status === 409){
alert('This record is locked and you cannot create a New Revision until the lock is released by the person currently editing it.');
}
})
.then((response) => {
this.get('store').pushPayload(response);
return response;
});
I want to handle this state here and only here, I want to prevent the error bubbling up to the handleErrors
call. I can't figure out how to prevent handleErrors
from getting called though.
How can I get this to resolve to an unerror state?
Due to complicated (and overly complicated design not done by myself...) reasons I can't remove the mixin and most of the time this is doing an ok job.
Aucun commentaire:
Enregistrer un commentaire