open-nomad/ui/app/utils/codes-for-error.js
2022-01-20 09:46:45 -05:00

16 lines
326 B
JavaScript

// Returns an array of error codes as strings for an Ember error object
export default function codesForError(error) {
const codes = [error.code];
if (error.errors) {
error.errors.forEach((err) => {
codes.push(err.status);
});
}
return codes
.compact()
.uniq()
.map((code) => '' + code);
}