vault/ui/app/utils/error-message.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

20 lines
720 B
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
/**
* deprecated in favor of api-error-message for use with the api service
* this util will be removed once Ember Data is fully removed
* new requests should be made with api service
* if Ember Data is still needed during the migration then this util may be used
*/
// accepts an error and returns error.errors joined with a comma, error.message or a fallback message
export default function (error, fallbackMessage = 'An error occurred, please try again') {
if (error instanceof Error && error?.errors && typeof error.errors[0] === 'string') {
return error.errors.join(', ');
}
return error?.message || fallbackMessage;
}