Skip to content

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

@alexandruchirita4192

Description

@alexandruchirita4192
Contributor
No description provided.

Activity

changed the title [-]The Castle Windsor Implementation doesn[/-] [+]The Castle Windsor Implementation doesn't work with exception handlers[/+] on May 12, 2022
alexandruchirita4192

alexandruchirita4192 commented on May 12, 2022

@alexandruchirita4192
ContributorAuthor

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

jbogard commented on May 16, 2022

@jbogard
Collaborator

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

alexandruchirita4192

alexandruchirita4192 commented on May 16, 2022

@alexandruchirita4192
ContributorAuthor

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

alexandruchirita4192 commented on May 16, 2022

@alexandruchirita4192
ContributorAuthor

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

alexandruchirita4192

alexandruchirita4192 commented on May 17, 2022

@alexandruchirita4192
ContributorAuthor

I added a pull request for this issue:
#742

alexandruchirita4192

alexandruchirita4192 commented on May 17, 2022

@alexandruchirita4192
ContributorAuthor

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

Thank you!

added a commit that references this issue on May 18, 2022
163ae5d
alexandruchirita4192

alexandruchirita4192 commented on May 18, 2022

@alexandruchirita4192
ContributorAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jbogard@alexandruchirita4192

        Issue actions

          The Castle Windsor Implementation doesn't work with exception handlers · Issue #741 · LuckyPennySoftware/MediatR