I'm trying to implement a switch statement that returns an error message based on the http status code. Here's what I have so far:
switch(true){
case err.status.test(/^4/): // 4xx
res.fail(err.status, err);
break;
case err.status.test(/^5/): // 5xx
res.error(err.status, err.message, {data: err});
break;
Can someone confirm if my regex is correct for this task?