Skip to content

Decorate errors automatically #27

Description

@aldesantis

Related to pragmarb/pragma-operation#2.

This pattern is very annoying:

options['result.response'] = Pragma::Operation::Response::NotFound
  .new
  .decorate_with(Pragma::Decorator::Error)

There is no reason for that decorate_with to exist, it's just boilerplate.

If result.response is a Pragma error response and it's not decorated, we should decorate it with Pragma::Decorator::Error automatically.

We either do it in pragma-operation or decorate the base operation here, e.g.

class Pragma::Operation::Base < Trailblazer::Operation
  def call(*)
    result = super
    result['result.response'] = '...'
  end
end

The problem with this is it cannot be overridden since it's not a step, and there is no way to ensure a step is actually run at the end of the operation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions