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

Fixing error title so it reflects that of the exception being thrown #532

Closed
wants to merge 1 commit into from

Conversation

cvallance
Copy link

Fixed the unhandled error title to be that of the exception that is being thrown. Somewhat related to this issue:
#346

Also

  • I think I fixed a bug where if you set maxItems the exception handler would never send the message
  • Removed RollbarMiddlewareException because there was no need for it potentially may have lost stacktrace by throwing a new error

@cvallance
Copy link
Author

Sorry @akornich I didn't assign you at the start and now it appears I can't edit it to assign you, most likely pebkac... but anyway, if you could take a look at this, that would be great.

@cvallance
Copy link
Author

@akornich Sorry, just making sure this on your radar... let me know if it's not appropriate and/or it needs tweaking.

@akornich
Copy link
Contributor

@cvallance , thanks for submitting the PR. We are having an internal discussion regarding the validity of the change from the system point of view. At the moment it looks like we can not take it as is since it will be causing a loss of some valuable context for many (if not most) of our users. The discussion now is mainly around having your change as optional/configurable only when preferred by a specific user.

@akornich akornich self-assigned this Jun 30, 2020
@akornich akornich added the refactoring Denotes codebase refactoring task label Jun 30, 2020
@akornich akornich added this to In progress in 2020-Q3 via automation Jun 30, 2020
@akornich
Copy link
Contributor

since we can not accept this PR as is - rejecting/closing it for now. we may include similar behavior offered by this PR but as a configurable option only.

@akornich akornich closed this Aug 27, 2020
2020-Q3 automation moved this from In progress to Done Aug 27, 2020
@cvallance
Copy link
Author

Sorry, just reviewing this 1 year later as we look to potentially move our dotnet stuff to join our python stuff in rollbar or vice versa.

@akornich Can you please elaborate on what you mean by "causing a loss of some valuable context fo many (if not most) of our users"...?

@akornich
Copy link
Contributor

akornich commented Aug 25, 2021

The Rollbar middleware component is intended to guard the "wrapped" part of the HTTP request processing middleware stack for uncaught (by that stack) exceptions. By wrapping any such exception within a RollbarException we clearly signify the fact that the guarded portion of the stack had a problem that was never fully handled and Rallbar middleware processed it. Also, the RollbarException wrapper provides a placeholder for us to attach any extra data about the request that caused the exception if necessary in the future. The original uncaught exception is fully preserved as the RollbarException's inner exception (that is a very common practice in .NET).

@cvallance
Copy link
Author

@akornich Sorry, but I disagree... this approach is causing headaches with our setup and I believe it should be changed.

By wrapping any such exception within a RollbarException we clearly signify the fact that the guarded portion of the stack had a problem that was never fully handled and Rallbar middleware processed it.

Just by simply re-throwing the original you are clearly signifying the fact that that guarded portion of the stack had a problem that was never fully handled. By throwing a new exception it signifies that there was a problem inside the middleware itself.

What benefit does wrapping it actually give?

There should be no need for other middleware providers to know that another middleware had processed it or not... either they get an exception or not, simple. It's actually confusing things because the rollbar middleware is now taking overship of any exception and any other middleware needs to be aware of this RollbarMiddlewareExecption and why they are getting it. All middleware should be complete independant and not coupled at all.

And on a similar note, there should be no need to attach anything in the future... no other middleware should need to know about rollbar, the rollbar middleware should do it's thing and then let all the other middleware do their thing without knowing about rollbar at all.

...

Secondly, the handling of the exception in rollbar appears to be in an else { } where the if is:

                    if (RollbarScope.Current != null 
                        && RollbarLocator.RollbarInstance.Config.MaxItems > 0
                        )
                    {

This appears to mean that if there is a RollbarScope.Current and the config specifies MaxItems, it will never call RollbarLocator.RollbarInstance.Critical(rollbarPackage); because it's in the else ...?

That is why I removed the else block in the MR.

@akornich
Copy link
Contributor

@cvallance , may I ask what sort of "headaches" does it create?

@cvallance
Copy link
Author

cvallance commented Aug 25, 2021

@akornich Basically the reasons I mention above... all other middleware that handles exceptions is now getting a RollbarMiddlewareExecption when they expect the original exception.

@akornich
Copy link
Contributor

I get that. But you can always change the order of the middleware components and have the RollbareMiddleware the last catch-all exception collector.
And in either case, you can always unwind a RollbarMiddlewareException by looking into its InnerException property.
What other middleware components do you use for exception handling (in addition to Rollbar)?

@cvallance
Copy link
Author

cvallance commented Aug 25, 2021

But you can always change the order of the middleware components and have the RollbareMiddleware the last catch-all exception collector.

This doesn't work if I have an exception handler that I want to be the one that "handles" the exception and doesn't throw for others down the line. Like the builtin ExceptionHandlerMiddleware which is now always reporting RollbarMiddlewareException instead of the originally thrown exception.

you can always unwind a RollbarMiddlewareException by looking into its InnerException property

I guess that's my whole point... I shouldn't have to do that because I don't want Rollbar abstractions leaking into my other middleware, especially if those other pieces of middleware are 3rd party or built in libraries where I can't alter the code.

Do you understand where I'm coming from?

Ps. I don't have the code in front of me, so I can't tell you what other middleware we are using... but the issue is just what I've outlined above, shouldn't matter too much what we're using.

@akornich
Copy link
Contributor

@cvallance , I see your point. We definetly will not be removing the RollbarMiddlewareException, but we can definetly add a config flag that would allow to opt-out the wrapping of the original exception. I think I should be able to add it in sometime next week.

@cvallance
Copy link
Author

Brilliant, thanks @akornich 😄

akornich added a commit to WideSpectrumComputing/Rollbar.NET that referenced this pull request Sep 17, 2021
- feat: resolve rollbar#532 - Make RollbarMiddlewareException wrapper optional based on config settings
@akornich akornich mentioned this pull request Sep 17, 2021
10 tasks
akornich added a commit that referenced this pull request Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Denotes codebase refactoring task
Projects
2020-Q3
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants