testing an error handler

not so great...

by Steven Senkus

JavaScript

function getErrorMsg(error) {
    return error.message || (error.data && typeof error.data === 'object') ? (error.data.message + " - " + error.data.errors.toString()) : null || (error.data && typeof error.data === 'string') ? (error.data.message + " - " + error.data.substring(0, 200)) : null || JSON.stringify(error);
}


var errorObj = {
    data: undefined,
    message: 'MESSAGE'
};
console.log(getErrorMsg(errorObj))