Call Montréal, Canada 524-949-6869

Blog

Thursday, January 13, 2011

Interfacing with Web Services? Checkout Tammer Saleh's "Coding for Failure"

Last year when interfacing with several Web services for a project I found Tammer Saleh's "Coding for Failure" indispensable. Although it was presented two years ago, it's far from out of date.

You can check it out on the Confreaks website and download the slides from here (the link on Tammer's website is broken).

Specifically I found Tammer's summary of different exceptions helpful which I have included here:

Net::HTTP exceptions

EXCEPTIONS = [Timeout::Error,
			  Errno::EINVAL,
			  Errno::ECONNRESET,
              EOFError,
              Net::HTTPBadResponse,
		      Net::HTTPHeaderSyntaxError,
			  Net::ProtocolError]

In addition to the exceptions, I would consider these as well:

VARIOUS_EXCEPTIONS = [Timeout::Error,
					  SocketError,
					  Net::HTTPFatalError,
					  Errno::ETIMEDOUT,
				      EOFError]

SMTP exceptions

SERVER_EXCEPTIONS = [TimeoutError, 
					 IOError,
				     Net::SMTPUnknownError, 
					 Net::SMTPServerBusy, 
				     Net::SMTPAuthenticationError]

CLIENT_EXCEPTIONS = [Net::SMTPFatalError, 
                     Net::SMTPSyntaxError]

EXCEPTIONS = SERVER_EXCEPTIONS + CLIENT_EXCEPTIONS

See slides for handling in controllers and rake tasks and notification using HopToad.

Developing Ruby on Rails applications and Radiant-based Content Management Systems in Montréal. Contact Firsthand.