Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the controller expect Domain Errors from the command bus? #116

Open
DanielRamosAcosta opened this issue Jan 27, 2022 · 2 comments
Open

Comments

@DanielRamosAcosta
Copy link

You have this at the CoursePutController.ts#L20:

    try {
      await this.commandBus.dispatch(createCourseCommand);
    } catch (error) {
      if (error instanceof CourseAlreadyExists) {
        res.status(httpStatus.BAD_REQUEST).send(error.message);
      } else {
        res.status(httpStatus.INTERNAL_SERVER_ERROR).json(error);
      }
    }

Right now this works because we are using an InMemoryCommandBus implementation. But, if we change the CommandBus implementation to one where we cannot expect the execution of the code (for example if we store this command in Kafka for later consumption), the implementation of this controller wouldn't work at all (because the use case will never get executed in this request, and it will never throw).

Is this true? Thanks!

@fraylopez
Copy link

To be precise, this implementation will work if you use Kafka but will never trigger the bad request catch. If Kafka itself is unavailable it will respond with internal server error though.

@rjurado01
Copy link

rjurado01 commented May 6, 2023

I also would like to know how errors in a boundex context are sent to other when you send command. In the course "DDD en TypeScript: Comunicación entre servicios y aplicaciones" this is not explained 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants