getErrorMessage
Returns an Error's message, if an Error instance is provided. Otherwise, a default message is returned.
import { getErrorMessage } from "@aedart/support/exceptions";
try {
throw new Error('Something went wrong!');
} catch(e) {
const msg = getErrorMessage(e, 'unknown error'); // Something went wrong!
}
// ---------------------------------------------------------------------------
try {
throw 'Something went wrong!';
} catch(e) {
const msg = getErrorMessage(e, 'unknown error'); // unknown error
}