Careful what you name things
On Friday I decided to create a new class called Failure. A Failure is stored anytime an unexpected exception is raised in our application. There are various subclasses to indicate many specific types of failures such as FrontendFailure and BackendFailure, each of which has different behavior. For example, FrontendFailure might send e-mail after_save. Other failure classes represent expected but unhandlable errors like "your template code is wrong". In those cases we can e-mail the user. We could even look through the failures to see if the user's problem has been fixed yet.
The failures table. (data is a serialized OpenStruct so subclasses can store anything they like)
create_table :failures do |t| t.column :type, :string t.column :exception_class, :string t.column :exception_message, :string t.column :backtrace, :text t.column :message, :string t.column :data, :text t.column :status, :integer t.column :created_at, :datetime t.column :updated_at, :datetime end
Sample usage.
begin do_something_big_and_complicated rescue ComplicatedError => e ComplicatedFailure.occurred e, "it happened again" end
Ok, so this works great. No problems. The problem was more subtle. Really subtle.
As I worked on this bit of code and started using it to debug various features, I started getting depressed. Not slit-your-wrists depressed but definitely bummed. Having just read Malcolm Gladwell's excellent Blink I can only say it was from constantly reading, typing, and thinking about "failure" over the course of a few hours.
Measure Map, it’s official
Jeff drops some info on Measure Map. Be sure to sign up for an invite, and keep an eye out for more in the near future.