[mapguide-internals] Patch for ticket 2365 (Include managed stack trace for MgException proxy classes)
Jackie Ng
jumpinjackie at gmail.com
Wed Feb 5 06:51:52 PST 2014
Hi All,
I've attached a patch for ticket 2365
http://trac.osgeo.org/mapguide/ticket/2365
The patch modifies the StackTrace and ToString() members of the
ManagedException base proxy class to include the .net stack trace in
addition to the C++ one returned by MgException.GetStackTrace()
Consider a program that would cause an MgException to be thrown (example
program source attached). The current exception stack trace looks like this:
- MgInitializeWebTier line 131 file InitializeWebTier.cpp
- MgInitializeWebTierInternal line 102 file InitializeWebTier.cpp
- MgConfiguration.LoadConfiguration line 113 file
d:\mg-trunk\mgdev\common\foundation\System/Configuration.cpp
And the ToString() looks like this
OSGeo.MapGuide.MgConfigurationLoadFailedException: Configuration file
"sdjfdkf" cannot be found or cannot be opened.
at
OSGeo.MapGuide.MapGuideApiPINVOKE.SWIGExceptionHelper.ThrowCustomException(String
className, IntPtr cptr) in
d:\mg-trunk\MgDev\Web\src\DotNetApi\Web\MapGuideApiPINVOKE.cs:line 76
at OSGeo.MapGuide.MapGuideApiPINVOKE.MgInitializeWebTier(String jarg1)
at OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(String configFile) in
d:\mg-trunk\MgDev\Web\src\DotNetApi\Web\MapGuideApi.cs:line 17
at ExceptionTest.Program.Func3() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 37
at ExceptionTest.Program.Func2() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 32
at ExceptionTest.Program.Func1() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 27
at ExceptionTest.Program.Main(String[] args) in c:\Users\Jackie
Ng\Documents\Visual Studio
2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 16
With this patch applied, the stack trace now looks like this:
at MgInitializeWebTier line 131 file InitializeWebTier.cpp
at MgInitializeWebTierInternal line 102 file InitializeWebTier.cpp
at MgConfiguration.LoadConfiguration line 113 file
d:\mg-trunk\mgdev\common\foundation\System/Configuration.cpp
==== [C++ <-> .net] ====
at
OSGeo.MapGuide.MapGuideApiPINVOKE.SWIGExceptionHelper.ThrowCustomException(String
className, IntPtr cptr) in
d:\mg-trunk\MgDev\Web\src\DotNetApi\Web\MapGuideApiPINVOKE.cs:line 76
at OSGeo.MapGuide.MapGuideApiPINVOKE.MgInitializeWebTier(String jarg1)
at OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(String configFile) in
d:\mg-trunk\MgDev\Web\src\DotNetApi\Web\MapGuideApi.cs:line 17
at ExceptionTest.Program.Func3() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 37
at ExceptionTest.Program.Func2() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 32
at ExceptionTest.Program.Func1() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 27
at ExceptionTest.Program.Main(String[] args) in c:\Users\Jackie
Ng\Documents\Visual Studio
2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 16
And the ToString() looks like this:
OSGeo.MapGuide.MgConfigurationLoadFailedException: Configuration file
"sdjfdkf" cannot be found or cannot be opened.
at MgInitializeWebTier line 131 file InitializeWebTier.cpp
at MgInitializeWebTierInternal line 102 file InitializeWebTier.cpp
at MgConfiguration.LoadConfiguration line 113 file
d:\mg-trunk\mgdev\common\foundation\System/Configuration.cpp
==== [C++ <-> .net] ====
at
OSGeo.MapGuide.MapGuideApiPINVOKE.SWIGExceptionHelper.ThrowCustomException(String
className, IntPtr cptr) in
d:\mg-trunk\MgDev\Web\src\DotNetApi\Web\MapGuideApiPINVOKE.cs:line 76
at OSGeo.MapGuide.MapGuideApiPINVOKE.MgInitializeWebTier(String jarg1)
at OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(String configFile) in
d:\mg-trunk\MgDev\Web\src\DotNetApi\Web\MapGuideApi.cs:line 17
at ExceptionTest.Program.Func3() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 37
at ExceptionTest.Program.Func2() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 32
at ExceptionTest.Program.Func1() in c:\Users\Jackie Ng\Documents\Visual
Studio 2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 27
at ExceptionTest.Program.Main(String[] args) in c:\Users\Jackie
Ng\Documents\Visual Studio
2013\Projects\ExceptionTest\ExceptionTest\Program.cs:line 16
As you can see, this patch greatly improves clarity of MgExceptions caught
on the .net side.
Please review. Thanks.
- Jackie
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Patch-for-ticket-2365-Include-managed-stack-trace-for-MgException-proxy-classes-tp5102080.html
Sent from the MapGuide Internals mailing list archive at Nabble.com.
More information about the mapguide-internals
mailing list