diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 054e8bc..466df71 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.7" + ".": "0.1.0" } diff --git a/Readme.adoc b/Readme.adoc index 799902a..eb360e4 100644 --- a/Readme.adoc +++ b/Readme.adoc @@ -11,12 +11,14 @@ minimal DSL for defining endpoints and middleware. == Features -* Declarative endpoint definitions with `endpoint`. -* Middleware support using `use`. -* Simple concurrency via `run` with a configurable number of instances. +* Declarative endpoint definitions with `#endpoint`. +* Grouping of endpoints with `#group` +* Simple concurrency via `#run` with a configurable number of instances. * JSON aware message wrapper that gracefully handles parse errors. +* Middleware support using `#use`. * Railway Oriented Design, using {dry-monads} for success and failure handling. * {dry-configurable} settings container. +* `#logger` defaults to SemanticLogger (adjustable as the `#logger=` setting) == Requirements diff --git a/lib/leopard/errors.rb b/lib/leopard/errors.rb index f7054a2..a66b24c 100644 --- a/lib/leopard/errors.rb +++ b/lib/leopard/errors.rb @@ -4,5 +4,6 @@ module Rubyists module Leopard class Error < StandardError; end class ConfigurationError < Error; end + class ResultError < Error; end end end diff --git a/lib/leopard/nats_api_server.rb b/lib/leopard/nats_api_server.rb index b8bd560..f2d12cc 100644 --- a/lib/leopard/nats_api_server.rb +++ b/lib/leopard/nats_api_server.rb @@ -202,10 +202,12 @@ def handle_message(raw_msg, handler) # Processes the result of the handler execution. # + # # @param wrapper [MessageWrapper] The message wrapper containing the raw message. # @param result [Dry::Monads::Result] The result of the handler execution. # # @return [void] + # @raise [ResultError] If the result is not a Success or Failure monad. def process_result(wrapper, result) case result in Dry::Monads::Success @@ -213,6 +215,9 @@ def process_result(wrapper, result) in Dry::Monads::Failure logger.error 'Error processing message: ', result.failure wrapper.respond_with_error(result.failure) + else + logger.error('Unexpected result: ', result:) + raise ResultError, "Unexpected Response from Handler, must respond with a Success or Failure monad: #{result}" end end end