Class: Goliath::Rack::ValidationError

Inherits:
Object
  • Object
show all
Defined in:
lib/goliath/rack/validation_error.rb

Overview

Middleware to catch Validation::Error exceptions and returns the [status code, no headers, :error => exception message]

Instance Method Summary (collapse)

Constructor Details

- (ValidationError) initialize(app)

A new instance of ValidationError



27
28
29
# File 'lib/goliath/rack/validation_error.rb', line 27

def initialize(app)
  @app = app
end

Instance Method Details

- (Object) call(env)



31
32
33
34
35
# File 'lib/goliath/rack/validation_error.rb', line 31

def call(env)
  @app.call(env)
rescue Goliath::Validation::Error => e
  [e.status_code, {}, {:error => e.message}]
end