2018-05-22 16:03:45 +01:00
|
|
|
import Mixin from '@ember/object/mixin';
|
2018-08-29 19:14:31 +01:00
|
|
|
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
2018-05-22 16:03:45 +01:00
|
|
|
|
2018-06-12 14:09:47 +01:00
|
|
|
import { INTERNAL_SERVER_ERROR as HTTP_INTERNAL_SERVER_ERROR } from 'consul-ui/utils/http/status';
|
2018-08-29 19:14:31 +01:00
|
|
|
export default Mixin.create(WithBlockingActions, {
|
|
|
|
errorCreate: function(type, e) {
|
2018-09-12 20:41:43 +01:00
|
|
|
if (e && e.errors && e.errors[0]) {
|
2018-08-29 19:14:31 +01: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 14:09:47 +01:00
|
|
|
}
|
2018-08-29 19:14:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return type;
|
2018-05-22 16:03:45 +01:00
|
|
|
},
|
|
|
|
});
|