29 lines
520 B
Ruby
29 lines
520 B
Ruby
require "json"
|
|
module Devops
|
|
module Exception
|
|
|
|
class DevopsError < StandardError
|
|
|
|
def http_status
|
|
500
|
|
end
|
|
|
|
def http_response
|
|
[self.http_status, self.http_headers, self.http_body]
|
|
end
|
|
|
|
def http_body
|
|
error_body = {message: self.message}
|
|
error_body[:error_type] = error_type if respond_to?(:error_type)
|
|
JSON.pretty_generate(error_body)
|
|
end
|
|
|
|
def http_headers
|
|
{"Content-Type" => "application/json"}
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|