= error.message.replace('{custom');
} else {
message = 'Generic message'
}
?
Yeah, but you don't need to mutate it
anything better than this?
const errorMap = [ [ testFn, replacementFn ], [ testFn2, replacementFn2 ] ]; ... for (const [ test, replacement ] of errorMap) { if (test(error)) { return replacement(error); } } return error;
I can ternary just used if...else for readability here
Обсуждают сегодня