U4-10407 - We should log unhandled exceptions that occur in webapi controllers and always have detailed errors returned to users even when not in debug mode

Created by Shannon Deminick 12 Sep 2017, 11:54:25 Updated by Sebastiaan Janssen 13 Sep 2017, 10:04:42

Tags: Unscheduled

Subtask of: UAASSCRUM-1073

We should log unhandled exceptions that occur in webapi controllers and always have detailed errors returned to users even when not in debug mode.

Currently in 'release' mode, if you get an unhandled exception (5xx), there is no log entry and there is no messages in the UI, or if there is one it is not detailed and just says 'an error occurred'

We can easily change this so that if a ysod occurs even in release mode we can still show it to the user since not showing one doesn't help anyone.

Comments

Shannon Deminick 12 Sep 2017, 12:00:32

PR https://github.com/umbraco/Umbraco-CMS/pull/2189

This:

  • Adds an IExceptionLogger to any controller inheriting from UmbracoAuthorizedApiController which is all of our back office controller - this logger will log exceptions to log4net
  • Adds a customer filter to the same base controller that enables detailed error messages all the time
  • Removes the addition ysodDialog in the JS helper - this was causing 2x ysod dialogs to be displayed. YSOD dialogs are handled globally in the angular app now when a 5xx error is detected

To test

  • Before using this new code, you can verify what isn't working: ** Change debug=false in web.config ** Change something like CurrentUserController change password method to throw an exception like InvalidOperationException ** Try to change your password, you'll get an error in the UI but it won't tell you anything and you won't see anything in the log ** I can't remember if you'll get 2x ysod dialogs with debug=false, if not, change debug=true and do the same thing and you'll get 2x ysod dialogs, no errors in your logs but at least the ysod dialogs tell you something
  • Now update to this PR ** Do those tests again - you will see an error in the log, you will see 1x ysod dialog in either debug true or false


Sebastiaan Janssen 13 Sep 2017, 10:04:14

All good, I'll cherry-pick for 7.6.7 too!


Priority: Normal

Type: Task

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.6.7

Sprint: Sprint 67

Story Points: 1

Cycle: