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

Exceptions raised in execution of command are wrapped if custom handler in place #6

Open
alexs1305 opened this issue Oct 1, 2018 · 1 comment

Comments

@alexs1305
Copy link
Member

Given the user is using EasyCommand.AspNetCore and the user has registered a custom handler and created commands. When a command raises an exception this exception type is wrapped in another exception raised in the handlers AfterExecutionAsync method. This breaks any catches on specific exception types outside of the command.
So with

Controller1.Get(){
    try{
        this.ExecuteAsync(this.Command<GetCommand>());
    }
    catch (SpecificException e)
    {
    }
}

if GetCommand throws SpecificException this will not be caught. Instead an exception of type Exception will be thrown with an inner exception of SpecificException

@alexs1305
Copy link
Member Author

This is by design, however the fact that it is throwing a generic System.Exception is probably not the best solution to this and it feels ambiguous. This should be changed instead to a custom exception that indicates that the handler has failed in running the command

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

1 participant