Skip to content

Instantly share code, notes, and snippets.

@takeru
Created April 15, 2010 07:51
Show Gist options
  • Select an option

  • Save takeru/366814 to your computer and use it in GitHub Desktop.

Select an option

Save takeru/366814 to your computer and use it in GitHub Desktop.
module AppEngine
module Datastore
class << self
alias convert_exceptions_ORIG convert_exceptions
def convert_exceptions
begin
convert_exceptions_ORIG do
yield
end
rescue com.google.apphosting.api.ApiProxy::ApplicationException => ex
case ex.message
when /ApplicationError: 2: too much contention on these datastore entities. please try again./
raise TransactionFailed, ex.message
when /ApplicationError: 5: Unknown/
raise Timeout, ex.message
when /ApplicationError: 90000: Deadlined while in scheduler/
raise Timeout, ex.message
else
raise ex
end
rescue com.google.apphosting.api.ApiProxy::ApiDeadlineExceededException => ex
raise Timeout, ex.message
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment