github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/utils/notify-forbidden.js (about)

     1  // An error handler to provide to a promise catch to set a
     2  // forbidden flag on the route
     3  import codesForError from './codes-for-error';
     4  export default function notifyForbidden(route) {
     5    return (error) => {
     6      if (codesForError(error).includes('403')) {
     7        route.set('isForbidden', true);
     8      } else {
     9        throw error;
    10      }
    11    };
    12  }