proper error message
This commit is contained in:
parent
fb6eb62063
commit
c0846a50da
@ -1,6 +1,10 @@
|
|||||||
require_relative "devops_error"
|
require_relative "devops_error"
|
||||||
class InvalidRecord < ::Devops::Exception::DevopsError
|
class InvalidRecord < ::Devops::Exception::DevopsError
|
||||||
|
|
||||||
|
# message could be a String or a hash like
|
||||||
|
# {
|
||||||
|
# error_data: [{:key=>:provider, :message=>"Value can not be undefined"}]
|
||||||
|
# }
|
||||||
def initialize msg
|
def initialize msg
|
||||||
if msg.is_a?(String)
|
if msg.is_a?(String)
|
||||||
super(msg)
|
super(msg)
|
||||||
@ -9,6 +13,17 @@ class InvalidRecord < ::Devops::Exception::DevopsError
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def message
|
||||||
|
if @object
|
||||||
|
messages = @object[:error_data].map do |error_item|
|
||||||
|
"#{error_item[:key]}: #{error_item[:message]}"
|
||||||
|
end
|
||||||
|
"Following errors occured: \n#{messages.join('\n')}"
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def http_status
|
def http_status
|
||||||
400
|
400
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user