Class: ReeRoda::BuildRouteErrors

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_roda/package/ree_roda/services/build_route_errors.rb

Instance Method Summary collapse

Instance Method Details

#call(route) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ree_lib/packages/ree_roda/package/ree_roda/services/build_route_errors.rb', line 9

def call(route)
  ree_object = route.action
  errors = recursively_extract_errors(ree_object)

  errors
    .select {
      _1.ancestors.include?(ReeErrors::Error) && status_from_error(_1)
    }
    .map {
      e = _1.new
      description = "type: **#{e.type}**, code: **#{e.code}**, message: **#{e.message}**"

      ErrorDto.new(
        status: status_from_error(_1),
        description: description
      )
    }
    .uniq { [_1.status, _1.description] }
end