cartodb/lib/carto/connector/errors.rb

31 lines
857 B
Ruby
Raw Normal View History

2020-06-15 10:58:47 +08:00
module Carto
class Connector
class ConnectorError < StandardError
attr_reader :user_name
def initialize(message: 'General error', user: nil, provider: nil)
@user_name = user && user.username
@provider_name = provider
message = message.to_s
message << " User: #{@user_name}" if @user_name
message << " Provider: #{@provider_name}" if @provider_name
super(message)
end
def error_code
CartoDB::Importer2::ERRORS_MAP.fetch(self.class, CartoDB::Importer2::ConnectorRunner::UNKNOWN_ERROR_CODE)
end
end
class InvalidParametersError < ConnectorError
end
class ConnectorsDisabledError < ConnectorError # ServiceDisabledError ?
def initialize(message: 'CARTO-Connector disabled', user: nil, provider: nil)
super
end
end
end
end