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

Allow non-error data items #42

Open
cacowen opened this issue Dec 29, 2022 · 0 comments
Open

Allow non-error data items #42

cacowen opened this issue Dec 29, 2022 · 0 comments

Comments

@cacowen
Copy link

cacowen commented Dec 29, 2022

I want to be able to set some Data items in the exception initially that can be pulled out when/if an exception is thrown. Like attaching metadata to a potential exception. However, when it comes time to call .ThrowIfContainsErrors(); it will throw because the Data count is > 0.

public class UserValidationException : Xeption
{
    public UserValidationException(Exception innerException)
        : base(message: "User validation errors occurred, please try again.", innerException)
    {
        Data.Add("StatusCode", StatusCodes.Status400BadRequest);
        Data.Add("ErrorCode", 400.01);
    }
}

Is this approach just bad, is there a way to already do this, or would it be useful to have a whitelisted list of keys that the ThrowIfContainsErrors will ignore?

Something like:

        Data.Add("StatusCode", StatusCodes.Status400BadRequest);
        Data.Add("ErrorCode", 400.01);
        NonErrorKeys.Add("StatusCode");
        NonErrorKeys.Add("ErrorCode");

and behind the scenes the methods for checking the Data within Xeption will ignore those keys.

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