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

18 lines
417 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
// An error handler to provide to a promise catch to set a
// forbidden flag on the route
import codesForError from './codes-for-error';
export default function notifyForbidden(route) {
return (error) => {
if (codesForError(error).includes('403')) {
route.set('isForbidden', true);
} else {
throw error;
}
};
}