module Tilda::Simple::Api::ErrorsHandler
Public Instance Methods
get(path, params = {})
click to toggle source
Calls superclass method
# File lib/tilda/simple/api/errors_handler.rb, line 5 def get(path, params = {}) handle_errors { super(path, params) } end
Private Instance Methods
api_error_class(response)
click to toggle source
# File lib/tilda/simple/api/errors_handler.rb, line 21 def api_error_class(response) case response['message'] when /Wrong Secret Key length|Wrong Public Key length/ Errors::InvalidCredentials when /Can't find project with this 'projectid' parameter/ Errors::ProjectNotFound when /Can't find page with this 'pageid' parameter/ Errors::PageNotFound else Errors::Error end end
check_response(response)
click to toggle source
# File lib/tilda/simple/api/errors_handler.rb, line 17 def check_response(response) raise api_error_class(response), response['message'] if response['status'] == 'ERROR' end
handle_errors(&block)
click to toggle source
# File lib/tilda/simple/api/errors_handler.rb, line 11 def handle_errors(&block) response = block.call check_response(response) if Api.config.raise_api_errors response end