open-nomad/ui/app/utils/notify-conflict.js
2023-04-10 15:36:59 +00:00

20 lines
458 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
// @ts-check
// Catches errors with conflicts (409)
// and allow the route to handle them.
import { set } from '@ember/object';
import codesForError from './codes-for-error';
export default function notifyConflict(parent) {
return (error) => {
if (codesForError(error).includes('409')) {
set(parent, 'hasConflict', true);
} else {
return error;
}
};
}