github.com/hernad/nomad@v1.6.112/ui/app/utils/message-from-adapter-error.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { ForbiddenError } from '@ember-data/adapter/error';
     7  
     8  // Returns a single string based on the response the adapter received
     9  export default function messageFromAdapterError(error, actionMessage) {
    10    if (error instanceof ForbiddenError) {
    11      return `Your ACL token does not grant permission to ${actionMessage}.`;
    12    }
    13  
    14    if (error.errors?.length) {
    15      return error.errors.mapBy('detail').join('\n\n');
    16    }
    17  
    18    return 'Unknown Error';
    19  }