Bug 10160 - Don't hide the internal Exceptions
Summary: Don't hide the internal Exceptions
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Other Other
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-08 07:56 UTC by Keiichi Iguchi
Modified: 2017-07-14 23:57 UTC (History)
4 users (show)

Tags:
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 GitHub or Developer Community 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:
Status:
RESOLVED FIXED

Description Keiichi Iguchi 2013-02-08 07:56:13 UTC
Description of Problem:
I often met the code like below in the mono's source.
---- 
catch(AAAException) {
  throw new BBBException("Some message");
}
---- 

Why don't you set original exception as innerException? (that contains important hint to resolve troubles)

For examples,
mono-3.0.3/mcs/class/corlib/Microsoft.Win32/UnixRegistryApi.cs
Line: 135
---- 
                                try {
                                        Directory.CreateDirectory (actual_basedir);
                                } catch (UnauthorizedAccessException){
                                        throw new SecurityException ("No access to the given key");
                                }
---- 
it should be,
---- 
                                try {
                                        Directory.CreateDirectory (actual_basedir);
                                } catch (UnauthorizedAccessException e){
                                        throw new SecurityException ("No access to the given key", e);
                                }
----
Comment 2 Atsushi Eno 2013-03-15 12:43:46 UTC
Thanks for the patch!

243c244
<       return SQLiteBase.SQLiteLastError(_sql);
---
>       return "Filename:" + _fileName + ":" + SQLiteBase.SQLiteLastError(_sql);

I think this is not bad, but since this is an override and it only changes SQLite3 part, so I am sort of awkward to apply this (I guess it's almost fine as people don't care about SQLite2 anymore though). I'd like to leave this to others to judge.


<                       if (!isAppVirtualPath && !virtualPath.StartsWith
(appVirtualPath, RuntimeHelpers.StringComparison))
<                               throw new InvalidOperationException
(String.Format ("Failed to map path '{0}'", virtualPath));
---
>                       if (!isAppVirtualPath && !virtualPath.StartsWith (appVirtualPath, RuntimeHelpers.StringComparison)) {
>                               //throw new InvalidOperationException (String.Format ("Failed to map path:'{0}' appVirtualPath:'{1}'", virtualPath, appVirtualPath));
>                       }

I believe this is not an intended change, right?

diff -r
mono-2.10.9/mcs/class/System.Web/System.Web.Security/SqliteMembershipProvider.cs
mono-2.10.9-iguchi/mcs/class/System.Web/System.Web.Security/SqliteMembershipProvider.cs
431c431,432
<                                                       throw new
ProviderException(Properties.Resources.ErrOperationAborted);
---
>                                                       // throw new ProviderException(Properties.Resources.ErrOperationAborted);
>                                                       throw new Exception(e.ToString() + '@' + m_ConnectionString);

This too.

908,909c909,911
<                                               Trace.WriteLine(e.ToString());
<                                               throw new
ProviderException(Properties.Resources.ErrOperationAborted);
---
>                                               // Trace.WriteLine(e.ToString());
>                                               // throw new ProviderException(Properties.Resources.ErrOperationAborted);
>                                               throw e;
1294c1296,1297
<                                                               throw new
ProviderException(Properties.Resources.ErrOperationAborted);
---
>                                                               // throw new ProviderException(Properties.Resources.ErrOperationAborted);
>                                                               throw e;

I guess these too, but in case it isn't, could you explain why these changes are better?


So, after the removal of above, the change looks like:


diff -r mono-2.10.9/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs
mono-2.10.9-iguchi/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs
243c244
<       return SQLiteBase.SQLiteLastError(_sql);
---
>       return "Filename:" + _fileName + ":" + SQLiteBase.SQLiteLastError(_sql);
Comment 3 Atsushi Eno 2013-03-15 12:45:44 UTC
I applied the suggestion on the bug description [master 1190937]. Thanks.

Next time it would be nice if you can use universal diff i.e. diff -u :)
Comment 4 Rodrigo Kumpera 2017-07-14 23:57:10 UTC
Patch was applied, marking the bug as fixed