I'm trying to figure out the best way to report non-fatal errors from a nodejs web service to a browser while also delivering the requested content.
Suppose I have a web service that makes images, using input from the user, perhaps parameters in the URL. Let's say it renders a text message in a particular font: http://www.example.com/makeimage.png?message=Hello%20World&font=Comic%20Sans The result would be a PNG image of the string "Hello World", but perhaps there is a non-fatal error in the user's parameters and I want to let them know that as well. For example perhaps the server does not have the font Comic Sans available, and it uses a fallback font instead. Obviously for fatal errors I have to show an error message to the user. But for non-fatal errors or warnings, the possibilities that occur to me are: * Ignore errors (bad: nobody sees them; user doesn't know about potential problems) * Log errors to the server's console only (bad: user never sees them; server admin can't force users to submit perfect input) * Send errors only; don't send requested output at all (bad: the specific error or warning might be unimportant to the user) * Render the error message(s) as text in the output image (bad: uglies up the user's output with potentially unimportant cruft; also harder to implement) * Send errors in custom HTTP headers (bad: user could inspect them but wouldn't know to look for them) * Send output and errors in a JSON object (bad: binary image data would be harder to use; user couldn't just use URL e.g. in an img tag's src attribute) * Send output and errors in a multipart/form-data or multipart/alternative response (bad: browsers don't support it, do they?) * Send output and errors in an HTTP status 207 Multi-Status response (bad: this is for WebDAV; browsers don't support it, do they?) Is there a best practice for this situation that I'm unaware of? -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
