You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
changed the title [-]The Castle Windsor Implementation doesn[/-][+]The Castle Windsor Implementation doesn't work with exception handlers[/+]on May 12, 2022
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
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):
1st way to solve is adding the exception type name in all handlers (like this, but there are many exception handlers in example project):
2nd way to solve is by removing the highlighted line (in Runner.cs):
Which way to solve you believe is better? Adding exception types everywhere (1st point) or removing checking by exception type (2nd point)?
Activity
[-]The Castle Windsor Implementation doesn[/-][+]The Castle Windsor Implementation doesn't work with exception handlers[/+]alexandruchirita4192 commentedon 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...
-- Handling Request
Exception of type 'MediatR.Examples.ExceptionHandler.ForbiddenException' was thrown.
Checking shared handler to catch exception by base type...
-- Handling Request
Exception of type 'MediatR.Examples.ExceptionHandler.ResourceNotFoundException' was thrown.
Checking base handler to catch any exception...
-- Handling Request
A task was canceled.
Selecting preferred handler to handle exception...
-- Handling Request
A task was canceled.
Selecting new handler to handle exception...
-- 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 commentedon May 16, 2022
Feel free to open a PR to fix! These examples are all provided by the community.
alexandruchirita4192 commentedon 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):

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

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

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 commentedon May 16, 2022
Also, please reopen the issue because I am opening the pull request in a few days after I fix more.
alexandruchirita4192 commentedon May 17, 2022
I added a pull request for this issue:
#742
alexandruchirita4192 commentedon May 17, 2022
When you review, check that everything goes well by running the Castle Windsor Examples, you could merge.
Thank you!
Merge pull request #742 from alexandruchirita4192/master
alexandruchirita4192 commentedon May 18, 2022
The pull request was created using the 1st way to fix from the question before, because I prefered adding code instead of deleting.