{"action":"created","issue":{"url":"https://api.github.com/repos/apsislabs/slayer/issues/54","repository_url":"https://api.github.com/repos/apsislabs/slayer","labels_url":"https://api.github.com/repos/apsislabs/slayer/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/apsislabs/slayer/issues/54/comments","events_url":"https://api.github.com/repos/apsislabs/slayer/issues/54/events","html_url":"https://github.com/apsislabs/slayer/issues/54","id":371219696,"node_id":"MDU6SXNzdWUzNzEyMTk2OTY=","number":54,"title":"Add \"Aggregate Error Messages\" Pattern?","user":{"login":"HenryKeiter","id":4380736,"node_id":"MDQ6VXNlcjQzODA3MzY=","avatar_url":"https://avatars2.githubusercontent.com/u/4380736?v=4","gravatar_id":"","url":"https://api.github.com/users/HenryKeiter","html_url":"https://github.com/HenryKeiter","followers_url":"https://api.github.com/users/HenryKeiter/followers","following_url":"https://api.github.com/users/HenryKeiter/following{/other_user}","gists_url":"https://api.github.com/users/HenryKeiter/gists{/gist_id}","starred_url":"https://api.github.com/users/HenryKeiter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HenryKeiter/subscriptions","organizations_url":"https://api.github.com/users/HenryKeiter/orgs","repos_url":"https://api.github.com/users/HenryKeiter/repos","events_url":"https://api.github.com/users/HenryKeiter/events{/privacy}","received_events_url":"https://api.github.com/users/HenryKeiter/received_events","type":"User","site_admin":false},"labels":[{"id":386901595,"node_id":"MDU6TGFiZWwzODY5MDE1OTU=","url":"https://api.github.com/repos/apsislabs/slayer/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":386901599,"node_id":"MDU6TGFiZWwzODY5MDE1OTk=","url":"https://api.github.com/repos/apsislabs/slayer/labels/wontfix","name":"wontfix","color":"ffffff","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-17T18:53:35Z","updated_at":"2018-10-17T22:46:40Z","closed_at":"2018-10-17T22:46:40Z","author_association":"NONE","body":"We do stuff like this frequently in Commands; might be worth canonizing.\r\n\r\n```\r\ndef argument_errors\r\n  errors = []\r\n\r\n  errors << foo_error\r\n  errors << bar_error\r\n  errors << baz_error\r\n\r\n  errors.compact!\r\n\r\n  return nil if errors.empty?\r\n  return errors\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/apsislabs/slayer/issues/comments/430815625","html_url":"https://github.com/apsislabs/slayer/issues/54#issuecomment-430815625","issue_url":"https://api.github.com/repos/apsislabs/slayer/issues/54","id":430815625,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDgxNTYyNQ==","user":{"login":"wkirby","id":579688,"node_id":"MDQ6VXNlcjU3OTY4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/579688?v=4","gravatar_id":"","url":"https://api.github.com/users/wkirby","html_url":"https://github.com/wkirby","followers_url":"https://api.github.com/users/wkirby/followers","following_url":"https://api.github.com/users/wkirby/following{/other_user}","gists_url":"https://api.github.com/users/wkirby/gists{/gist_id}","starred_url":"https://api.github.com/users/wkirby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wkirby/subscriptions","organizations_url":"https://api.github.com/users/wkirby/orgs","repos_url":"https://api.github.com/users/wkirby/repos","events_url":"https://api.github.com/users/wkirby/events{/privacy}","received_events_url":"https://api.github.com/users/wkirby/received_events","type":"User","site_admin":false},"created_at":"2018-10-17T22:46:40Z","updated_at":"2018-10-17T22:46:40Z","author_association":"CONTRIBUTOR","body":"So the issue I see with this is that commands don't check errors in a single place: the failure of a command is necessarily in sequence with other business logic.\r\n\r\nI could see the eventual use of a more structured `flunk!` call, maybe something like `flunk_with! :function` that would return a structured object that is proxied to the `flunk!` call. Something like:\r\n\r\n```ruby\r\nclass FooCommand\r\n  def call(foo_form:)\r\n    flunk_with! :check_arguments, foo_form\r\n  end\r\n\r\n  private\r\n\r\n  def check_arguments(form)\r\n    unless form.valid?\r\n      return Slayer::Result.new(\r\n        valid: false,\r\n        message: form.errors.messages.full_sentences,\r\n        value: form\r\n      )\r\n    end\r\n  end\r\nend\r\n```"}}
{"actor":{"display_login":"wkirby"}}