In our codebase I stumbled upon this :
try {
const response = await fetch('https://xxxxxxxxxxxxx');
if (response.statusCode === HttpResponseStatus.OK) {
console.log(e.response);
} else {
throw new Error(response.statusCode);
}
} catch (e) {
console.error(e.response); // <-- ???!!!???
if(e.statusCode === ...) { // <-- ??!??
consople.error("extra logging")
}
}
I am extremely puzzled because this seems like a massive bug, as e
is supposed to be an error and should therefore not contain a .response
or a .statusCode
field.
However it’s used everywhere in our code base.
Is it just a case of copy-pasting the same bug a million times?
1