So what you did is perfectly correct and functional, and if you're hurt by the I-think-there's-a-better-way-of-doing-this comments then don't continue reading.
So what you made (Which is perfectly functional) is:
You'd sent for each error different parameters, like the stylefile (which is a very good way of assigning styles) and your errorMessage. Which is perfectly functional, although, is this the place to put your image source? I believe if you hadn't added your img attribute in your error object it would be better, for the following reason; Imagine I've more data that separates 404 from 500, will I put everything in that object? Does it sound correct? If it does then it's perfectly fine\functional. But if it doesn't, then I would suggest that you make two separate error pages (or at least two conditions in the same error page if statusCode === 404 do404Stuff(); else do500Stuff();.
So what you did is perfectly correct and functional, and if you're hurt by the I-think-there's-a-better-way-of-doing-this comments then don't continue reading. So what you made (Which is perfectly functional) is: You'd sent for each error different parameters, like the
stylefile
(which is a very good way of assigning styles) and yourerrorMessage
. Which is perfectly functional, although, is this the place to put your image source? I believe if you hadn't added yourimg
attribute in your error object it would be better, for the following reason; Imagine I've more data that separates 404 from 500, will I put everything in that object? Does it sound correct? If it does then it's perfectly fine\functional. But if it doesn't, then I would suggest that you make two separate error pages (or at least two conditions in the same error pageif statusCode === 404 do404Stuff(); else do500Stuff();
.