cqrs icon indicating copy to clipboard operation
cqrs copied to clipboard

CommandHandleException with Command Name not command uuid

Open Dracks opened this issue 1 year ago • 2 comments

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

Currently, we are having some random problems with the commandHandler that nestjs doesn't found the commandHandler, and this trigger the CommandHandlerException with an UUID, which makes it super dificult to debug.

Describe the solution you'd like

I would like that on the following line: https://github.com/nestjs/cqrs/blob/master/src/command-bus.ts#L61

The name passed to the exception is the real name of the class, and not the ID. Currently I needed to go to the sourcecode in production, look at the line of the exception to search what command was failing.

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Makes thinks easy to debug, I replicated a similar error here: https://codesandbox.io/p/sandbox/exciting-wildflower-kqx3ky

And you can see the error is not really user friendly, If I had 4 or 5 commands, and after a refactor I get that error, It's not straight forward.

Dracks avatar Sep 15 '23 14:09 Dracks

Would you like to create a PR for this issue?

kamilmysliwiec avatar Sep 18 '23 08:09 kamilmysliwiec

I will try it. Give me some time.

Dracks avatar Sep 18 '23 10:09 Dracks