Code snippet of the day

Nov 04, 2009 23:00


Handling exceptions is tricky. Opinions vary on whether you should catch and report to a central error handler, only catch exceptions you know how to recover from, or fail-fast and allow exceptions to bubble up until the program exits.

Our email management API takes a different tack:

void CEmailManagerExtension::CMDCreateMailbox() { try { // ...do some work... } catch (...) { rCtxt.Redirect("http://www.ebay.com"); } }
Obviously if something goes wrong with the create-mailbox API call, the correct response is to send the client to eBay. Maybe they can buy error handling that doesn't suck.

This code has existed since 2002 - no word on whether eBay pays us a revshare for traffic.
Previous post Next post
Up