caremyway-client/src/actions/common.actions.js

14 lines
409 B
JavaScript
Raw Permalink Normal View History

/**
* Given an exception return the list of errors, the singular error, or generic error
* @param {object|string} exception - axios returned exception
*/
export function parseError(exception) {
let response = exception.response || {};
let data = response.data || {};
let err = "" + exception;
if (response.status) {
err = `${response.status} ${response.statusText}`;
}
return data || err
}