Bug 2740 - MonoDevelop should report unhandled exceptions as well as crashes
Summary: MonoDevelop should report unhandled exceptions as well as crashes
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Cody Russell
Depends on:
Reported: 2012-01-04 22:45 UTC by Mikayla Hutchinson [MSFT]
Modified: 2015-07-30 10:33 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mikayla Hutchinson [MSFT] 2012-01-04 22:45:18 UTC
Currently the crash reporter only reports errors that reach the global unhandled error handlers. There are many other places that we report exceptions that should also go to the error reporter.

Maybe we should just route MessageService.ShowException through the error reporter, though there may be a few uses which are not appropriate for this, and we'd also have to figure out how to collect the "detail" of the message.

We should also review everywhere that logs messages to the console and report whichever of those are appropriate too, if automatic reporting is enabled, though in most cases they aren't worth showing a UI for.
Comment 1 Mikayla Hutchinson [MSFT] 2012-01-12 21:35:06 UTC
Unfortunately there are 80 places where we call ShowException. We can't just route  MessageService.ShowException through the crash handler because:
* some of them contain additional information which we would not currently collect
* some of the additional information should not be collected, for example filenames
* some of them represent a specific operation failing and we should show this information if we can
* some of them shouldn't be reported as they wouldn't be caused by actual bugs - in such cases we shouldn't even show exceptions

Also, in many cases, we don't log the exception. I suggest we could fix this with a simple API:

LogAndShowException  (
    // localized and displayed to user
    // and can contain identifying information
    // e.g. "Failed to save the file '{0}'"
    string displayMessage,
    // anonymized, English, submitted in crash reports
    string logMessage, // "Failed to save a file"
    Exception exception

and the silent version, which would write to the log file and only upload if the user has automatic reporting enabled.

LogException  (
    Exception exception,
    string logMessage, // "Failed to save a file"