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

The Castle Windsor Implementation doesn't work with exception handlers #741

Closed
alexandruchirita4192 opened this issue May 12, 2022 · 7 comments

Comments

@alexandruchirita4192
Copy link
Contributor

No description provided.

@alexandruchirita4192 alexandruchirita4192 changed the title The Castle Windsor Implementation doesn The Castle Windsor Implementation doesn't work with exception handlers May 12, 2022
@alexandruchirita4192
Copy link
Contributor Author

alexandruchirita4192 commented May 12, 2022

Hi,

The Castle Windsor implementation in MediatR.Examples.Windsor, doesn't work with exception handlers. Below is the result from running the application (excluding what doesn't matter):

Checking handler to catch exact exception...

  • Starting Up
    -- Handling Request
    Exception of type 'MediatR.Examples.ExceptionHandler.ForbiddenException' was thrown.

Checking shared handler to catch exception by base type...

  • Starting Up
    -- Handling Request
    Exception of type 'MediatR.Examples.ExceptionHandler.ResourceNotFoundException' was thrown.

Checking base handler to catch any exception...

  • Starting Up
    -- Handling Request
    A task was canceled.

Selecting preferred handler to handle exception...

  • Starting Up
    -- Handling Request
    A task was canceled.

Selecting new handler to handle exception...

  • Starting Up
    -- Handling Request
    Exception of type 'MediatR.Examples.ExceptionHandler.ServerException' was thrown.

[... (excluded here too, but all was ok) ...]

Handler for inherited request with same exception used.............N
Handler for inherited request with base exception used.............N
Handler for request with less specific exception used by priority..N
Preferred handler for inherited request with base exception used...N
Overridden handler for inherited request with same exception used..N

@jbogard
Copy link
Owner

jbogard commented May 16, 2022

Feel free to open a PR to fix! These examples are all provided by the community.

@jbogard jbogard closed this as completed May 16, 2022
@alexandruchirita4192
Copy link
Contributor Author

alexandruchirita4192 commented May 16, 2022

I have a working in progress that solves a lot of issues for the Castle Windsor examples (including some streams that were not tested before).

I have one question regarding the way to solve though, regarding the following method used for testing if an exception handler was handled (from Runner.cs):
image

1st way to solve is adding the exception type name in all handlers (like this, but there are many exception handlers in example project):
image

2nd way to solve is by removing the highlighted line (in Runner.cs):
image

Which way to solve you believe is better? Adding exception types everywhere (1st point) or removing checking by exception type (2nd point)?

Thank you.

@alexandruchirita4192
Copy link
Contributor Author

Also, please reopen the issue because I am opening the pull request in a few days after I fix more.

@jbogard jbogard reopened this May 17, 2022
@alexandruchirita4192
Copy link
Contributor Author

I added a pull request for this issue:
#742

@alexandruchirita4192
Copy link
Contributor Author

When you review, check that everything goes well by running the Castle Windsor Examples, you could merge.

Thank you!

jbogard added a commit that referenced this issue May 18, 2022
Fix "The Castle Windsor Implementation doesn't work with exception handlers #741" issue
@alexandruchirita4192
Copy link
Contributor Author

The pull request was created using the 1st way to fix from the question before, because I prefered adding code instead of deleting.

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

2 participants