mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
20 lines
521 B
JavaScript
20 lines
521 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { ForbiddenError } from '@ember-data/adapter/error';
|
|
|
|
// Returns a single string based on the response the adapter received
|
|
export default function messageFromAdapterError(error, actionMessage) {
|
|
if (error instanceof ForbiddenError) {
|
|
return `Your ACL token does not grant permission to ${actionMessage}.`;
|
|
}
|
|
|
|
if (error.errors?.length) {
|
|
return error.errors.mapBy('detail').join('\n\n');
|
|
}
|
|
|
|
return 'Unknown Error';
|
|
}
|