2018-05-22 15:03:45 +00:00
|
|
|
import Mixin from '@ember/object/mixin';
|
2018-08-29 18:14:31 +00:00
|
|
|
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
2018-05-22 15:03:45 +00:00
|
|
|
|
2018-06-12 13:09:47 +00:00
|
|
|
import { INTERNAL_SERVER_ERROR as HTTP_INTERNAL_SERVER_ERROR } from 'consul-ui/utils/http/status';
|
2018-08-29 18:14:31 +00:00
|
|
|
export default Mixin.create(WithBlockingActions, {
|
|
|
|
errorCreate: function(type, e) {
|
2018-09-12 19:41:43 +00:00
|
|
|
if (e && e.errors && e.errors[0]) {
|
2018-08-29 18:14:31 +00:00
|
|
|
const error = e.errors[0];
|
|
|
|
if (parseInt(error.status) === HTTP_INTERNAL_SERVER_ERROR) {
|
|
|
|
if (error.detail.indexOf('duplicate intention found:') === 0) {
|
|
|
|
return 'exists';
|
2018-06-12 13:09:47 +00:00
|
|
|
}
|
2018-08-29 18:14:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return type;
|
2018-05-22 15:03:45 +00:00
|
|
|
},
|
|
|
|
});
|