[mapguide-commits] r9754 - in sandbox/jng/flatten_exceptions: UnitTest/Common/FoundationTest UnitTest/Common/FoundationTest/DotNetUnmanagedApi UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests Web/src/mapviewerjava Web/src/mapviewernet Web/src/mapviewerphp Web/src/schemareport
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Nov 5 01:10:05 PST 2020
Author: jng
Date: 2020-11-05 01:10:04 -0800 (Thu, 05 Nov 2020)
New Revision: 9754
Modified:
sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/DotNetUnmanagedApi/catchall.code
sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/FoundationTest.cpp
sandbox/jng/flatten_exceptions/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/MapTests.cs
sandbox/jng/flatten_exceptions/Web/src/mapviewerjava/mainframe.jsp
sandbox/jng/flatten_exceptions/Web/src/mapviewernet/mainframe.aspx
sandbox/jng/flatten_exceptions/Web/src/mapviewerphp/mainframe.php
sandbox/jng/flatten_exceptions/Web/src/schemareport/showclass.php
sandbox/jng/flatten_exceptions/Web/src/schemareport/showgeom.php
Log:
Fix up MgException handling in downstream api consumers / test code.
Modified: sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/DotNetUnmanagedApi/catchall.code
===================================================================
--- sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/DotNetUnmanagedApi/catchall.code 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/DotNetUnmanagedApi/catchall.code 2020-11-05 09:10:04 UTC (rev 9754)
@@ -3,6 +3,6 @@
{
string s = proxyfname;
wstring fname = MgUtil::MultiByteToWideChar(s);
- MgUnclassifiedException* e = new MgUnclassifiedException(fname, __LINE__, __WFILE__, NULL, L"", NULL);
+ MgException* e = new MgException(MgExceptionCodes::MgUnclassifiedException, fname, __LINE__, __WFILE__, NULL, L"", NULL);
ThrowDotNetExceptionWrapper(e);
}
Modified: sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/FoundationTest.cpp
===================================================================
--- sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/FoundationTest.cpp 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/UnitTest/Common/FoundationTest/FoundationTest.cpp 2020-11-05 09:10:04 UTC (rev 9754)
@@ -63,10 +63,17 @@
{
config->SetProperties(L"GeneralProperties", propCol);
}
- catch (MgConfigurationException* e)
+ catch (MgException* e)
{
- failed = true;
- e->Release();
+ if (e->GetExceptionCodes() == MgExceptionCodes::MgConfigurationException)
+ {
+ failed = true;
+ e->Release();
+ }
+ else
+ {
+ e->Raise();
+ }
}
if (!failed)
Modified: sandbox/jng/flatten_exceptions/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/MapTests.cs
===================================================================
--- sandbox/jng/flatten_exceptions/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/MapTests.cs 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/MapTests.cs 2020-11-05 09:10:04 UTC (rev 9754)
@@ -71,9 +71,9 @@
Assert.Fail("Expected MgUnsupportedTileProviderException to be thrown");
}
- catch (MgUnsupportedTileProviderException)
+ catch (MgException ex)
{
-
+ Assert.AreEqual(MgException::MgUnsupportedTileProviderException, ex.GetExceptionCode());
}
}
}
Modified: sandbox/jng/flatten_exceptions/Web/src/mapviewerjava/mainframe.jsp
===================================================================
--- sandbox/jng/flatten_exceptions/Web/src/mapviewerjava/mainframe.jsp 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/Web/src/mapviewerjava/mainframe.jsp 2020-11-05 09:10:04 UTC (rev 9754)
@@ -549,26 +549,21 @@
response.getWriter().write(templ);
response.setContentLength(templ.length());
}
-catch(MgUserNotFoundException e)
-{
- RequestAuthentication(response);
- return;
-}
-catch(MgUnauthorizedAccessException e)
-{
- RequestAuthentication(response);
- return;
-}
-catch(MgAuthenticationFailedException e)
-{
- RequestAuthentication(response);
- return;
-}
catch(MgException e)
{
- String msg = EscapeForHtml(e.GetExceptionMessage());
- response.getWriter().write(msg);
- response.setContentLength(msg.length());
+ if (e.GetExceptionCode() == MgExceptionCodes.MgUnauthorizedAccessException ||
+ e.GetExceptionCode() == MgExceptionCodes.MgUserNotFoundException ||
+ e.GetExceptionCode() == MgExceptionCodes.MgAuthenticationFailedException)
+ {
+ RequestAuthentication(response);
+ return;
+ }
+ else
+ {
+ String msg = EscapeForHtml(e.GetExceptionMessage());
+ response.getWriter().write(msg);
+ response.setContentLength(msg.length());
+ }
}
catch(Exception ne)
{
Modified: sandbox/jng/flatten_exceptions/Web/src/mapviewernet/mainframe.aspx
===================================================================
--- sandbox/jng/flatten_exceptions/Web/src/mapviewernet/mainframe.aspx 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/Web/src/mapviewernet/mainframe.aspx 2020-11-05 09:10:04 UTC (rev 9754)
@@ -546,25 +546,20 @@
String templ = Substitute(template, args);
Response.Write(templ);
}
- catch (MgUnauthorizedAccessException)
- {
- RequestAuthentication();
- return;
- }
- catch (MgUserNotFoundException)
- {
- RequestAuthentication();
- return;
- }
- catch (MgAuthenticationFailedException e)
- {
- RequestAuthentication();
- return;
- }
catch (MgException e)
{
- String errorMsg = EscapeForHtml(e.GetDetails());
- Response.Write(errorMsg);
+ if (e.GetExceptionCode() == MgExceptionCodes.MgUnauthorizedAccessException ||
+ e.GetExceptionCode() == MgExceptionCodes.MgUserNotFoundException ||
+ e.GetExceptionCode() == MgExceptionCodes.MgAuthenticationFailedException)
+ {
+ RequestAuthentication();
+ return;
+ }
+ else
+ {
+ String errorMsg = EscapeForHtml(e.GetDetails());
+ Response.Write(errorMsg);
+ }
}
catch (Exception ne)
{
Modified: sandbox/jng/flatten_exceptions/Web/src/mapviewerphp/mainframe.php
===================================================================
--- sandbox/jng/flatten_exceptions/Web/src/mapviewerphp/mainframe.php 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/Web/src/mapviewerphp/mainframe.php 2020-11-05 09:10:04 UTC (rev 9754)
@@ -541,27 +541,28 @@
$vpath . "viewoptions.php",
$frameset);
}
- catch(MgUserNotFoundException $e)
- {
- requestAuthentication();
- }
- catch(MgAuthenticationFailedException $e)
- {
- requestAuthentication();
- }
catch(MgException $e)
{
- // This should be a 500 error of some sort, but
- // in order to give a nice custom error message, it looks as
- // if we shortcut things by using a 200 status.
- $shortError = $e->GetExceptionMessage();
- $longErrorMsg = EscapeForHtml($e->GetDetails());
- header("HTTP/1.1 200 ");
- header('Content-Type: text/html; charset=utf-8');
- header("Status: 200 {$shortError}");
- echo "<html>\n<body>\n";
- echo $longErrorMsg;
- echo "</body>\n</html>\n";
+ if ($e->GetExceptionCode() == MgExceptionCodes::MgUnauthorizedAccessException ||
+ $e->GetExceptionCode() == MgExceptionCodes::MgUserNotFoundException ||
+ $e->GetExceptionCode() == MgExceptionCodes::MgAuthenticationFailedException)
+ {
+ requestAuthentication();
+ }
+ else
+ {
+ // This should be a 500 error of some sort, but
+ // in order to give a nice custom error message, it looks as
+ // if we shortcut things by using a 200 status.
+ $shortError = $e->GetExceptionMessage();
+ $longErrorMsg = EscapeForHtml($e->GetDetails());
+ header("HTTP/1.1 200 ");
+ header('Content-Type: text/html; charset=utf-8');
+ header("Status: 200 {$shortError}");
+ echo "<html>\n<body>\n";
+ echo $longErrorMsg;
+ echo "</body>\n</html>\n";
+ }
}
catch(Exception $ne)
{
Modified: sandbox/jng/flatten_exceptions/Web/src/schemareport/showclass.php
===================================================================
--- sandbox/jng/flatten_exceptions/Web/src/schemareport/showclass.php 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/Web/src/schemareport/showclass.php 2020-11-05 09:10:04 UTC (rev 9754)
@@ -148,13 +148,12 @@
if($totalEntries>$maxEntries)
DisplayPaging($index, $resName, $schemaName, $className, $sessionId, $maxEntries, $currentPage, $maxPage, $lastEntry);
}
- catch (MgSessionExpiredException $s)
- {
- echo ErrorMessages::SessionExpired;
- }
catch (MgException $e)
{
- echo $e->GetExceptionMessage();
+ if ($e->GetExceptionCode() == MgExceptionCodes::MgSessionExpiredException)
+ echo ErrorMessages::SessionExpired;
+ else
+ echo $e->GetExceptionMessage();
}
?>
Modified: sandbox/jng/flatten_exceptions/Web/src/schemareport/showgeom.php
===================================================================
--- sandbox/jng/flatten_exceptions/Web/src/schemareport/showgeom.php 2020-10-29 09:37:14 UTC (rev 9753)
+++ sandbox/jng/flatten_exceptions/Web/src/schemareport/showgeom.php 2020-11-05 09:10:04 UTC (rev 9754)
@@ -160,16 +160,19 @@
$resId = new MgResourceIdentifier($resName);
$resourceSrvc->SetResource($resId, $byteSource->GetReader(), null);
}
- catch (MgSessionExpiredException $s)
- {
- $validSession = 0;
- echo ErrorMessages::SessionExpired;
- }
catch (MgException $mge)
{
- $validSession = 0;
- echo $mge->GetExceptionMessage();
- echo $mge->GetStackTrace();
+ if ($mge->GetExceptionCode() == MgExceptionCodes::MgSessionExpiredException)
+ {
+ $validSession = 0;
+ echo ErrorMessages::SessionExpired;
+ }
+ else
+ {
+ $validSession = 0;
+ echo $mge->GetExceptionMessage();
+ echo $mge->GetStackTrace();
+ }
}
catch (Exception $e)
{
More information about the mapguide-commits
mailing list