+ :status => :bad_request, :content_type => "text/plain" }
+ end
+ end
+
+ ##
+ # raised when user input couldn't be parsed
+ class APIBadUserInput < APIError
+ def initialize(message)
+ @message = message
+ end
+
+ def render_opts
+ { :text => @message, :content_type => "text/plain", :status => :bad_request }
+ end
+ end
+
+ ##
+ # raised when an API call is made using a method not supported on that URI
+ class APIBadMethodError < APIError
+ def initialize(supported_method)
+ @supported_method = supported_method
+ end
+
+ def render_opts
+ { :text => "Only method #{@supported_method} is supported on this URI.", :status => :method_not_allowed }
+ end
+ end
+
+ ##
+ # raised when an API call takes too long
+ class APITimeoutError < APIError
+ def render_opts
+ { :text => "Request timed out", :status => :request_timeout }
+ end
+
+ def to_s
+ "Request timed out"