2022-11-23 22:33:41 +00:00
|
|
|
// 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') {
|
2022-12-01 01:24:40 +00:00
|
|
|
if (error instanceof Error && error?.errors) {
|
2022-11-23 22:33:41 +00:00
|
|
|
return error.errors.join(', ');
|
|
|
|
}
|
|
|
|
return error?.message || fallbackMessage;
|
|
|
|
}
|