Sha256: 818c5cc585be7ca28d159c40635ad6962f9237f551da682ea5ded343e76adb0a
Contents?: true
Size: 990 Bytes
Versions: 2
Compression:
Stored size: 990 Bytes
Contents
module Praxis module Responses class ValidationError < BadRequest def initialize(summary:, errors: nil, exception: nil, documentation: nil, **opts) super(**opts) @headers['Content-Type'] = 'application/json' #TODO: might want an error mediatype @errors = errors unless @errors # The exception message will the the only error if no errors are passed in @errors = [exception.message] if exception && exception.message end @exception = exception @summary = summary @documentation = documentation end def format!(**_args) @body = {name: 'ValidationError', summary: @summary } @body[:errors] = @errors if @errors if @exception && @exception.cause @body[:cause] = {name: @exception.cause.class.name, message: @exception.cause.message} end @body[:documentation] = @documentation if @documentation @body end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
praxis-0.22.pre.2 | lib/praxis/responses/validation_error.rb |
praxis-0.22.pre.1 | lib/praxis/responses/validation_error.rb |