[mapguide-internals] Exception Handling in Init Coord System - Patch for CoordSysCatalog

UV uvwild at gmail.com
Mon Apr 27 00:18:43 EDT 2009


Hugues,
yes, I think that would be the clean way to do it.
However, looking at how many ace_debug messages I get when firing up the 
server
(e.g. 200 lines regarding problems with the fonts)
I think just adding debug output is a practical and much more simple 
approach.
In the end its about telling the user where to put the coord 
systems..... not only that the server failed loading them.

Hugues Wisniewski wrote:
> Hi,
>
> So, the reason why you're unhappy with this behavior is the quality of the error report message?
> That's a fair statement. We could also add a value like "lsInitializationFailedInvalidDictionaryPath" to the enum value returned by MgCoordinateSystemCatalog::GetLibraryStatus()
>
> enum LibraryStatus
> {
>     lsInitialized    = 0,
>     lsInitializationFailed,
>     lsLoadFailed
> };
>
> For info, the comment refers to the possibility of doing the following.
> Those who want to customize the path and even the file names dynamically after install can do it writing something like this:
>
>     try
>     {
>         MgCoordinateSystemFactory factory;
>         Ptr<MgCoordinateSystemCatalog> pCatalog=factory.GetCatalog();
>         pCatalog->SetDictionaryDir("my custom folder");
>
>         Ptr<MgCoordinateSystemDictionary> pCsDict=pCatalog->GetCoordinateSystemDictionary();
>         pCsDict->SetFileName("myCoordSysFile.csd");
>
>         Ptr<MgCoordinateSystemDatumDictionary> pDtDict=pCatalog->GetDatumDictionary();
>         pDtDict->SetFileName("myDatumFile.csd");
>
>         Ptr<MgCoordinateSystemEllipsoidDictionary> pElDict=pCatalog->GetEllipsoidDictionary();
>         pElDict->SetFileName("myElFile.csd");
>         
>         Ptr<MgCoordinateSystemCategoryDictionary> pCtDict=pCatalog->GetCategoryDictionary();
>         pCtDict->SetFileName("myCategoryFile.csd");
>     }
>     catch (MgException *pE)
>     {
>         //do something
>     }
>
>
>   
>> did not manage to print the used Directory path into the logfile
>>     
Well, this is about being able to place a wstring in to the ACE_LOG 
method. Neither heap nor stack allocated strings would print correctly.
This might also be a threading issue as it works when providing literals....

> MgCoordinateSystemCatalog::GetDictionaryDir() maybe?
>
> Hugues
>
> -----Original Message-----
> From: mapguide-internals-bounces at lists.osgeo.org [mailto:mapguide-internals-bounces at lists.osgeo.org] On Behalf Of UV
> Sent: Friday, April 24, 2009 5:38 AM
> To: MapGuide Internals Mail List
> Subject: [mapguide-internals] Exception Handling in Init Coord System - Patch for CoordSysCatalog
>
> I just found the place in the code which properly frustrated most novices so far.....
>
> Very good explanation of why to catch the exception ... but utterly wrong in its effect for too many use cases.
>
> We have 2 main user groups... the big one using defaults and the others.
> The choice made to suppress all exception information for most users so the the small user group not needing this information does not have to see it is wrong IMHO.
>
> The messages need to be shown so we know whats happening.
> The current exception handling is really frustrating as it ommits all useful info and says.... Not Working.
>
> I added some ACE_DEBUG level messages to CoordSysCatalog..... I did not manage to print the used Directory path into the logfile.... so any input is appreciated.
>
> cheers
>
> ------------------------------------------------------------------------------------------------------------------------
>
> CoordSysCatalog.cpp:#89
>     try
>     {
>         SetDefaultDictionaryDirAndFileNames();
>     }
>     catch (MgException* pEPath)
>     {
>         //We do not throw this exception because:
>         //- we might just not care about the default values
>         //of the directory and file names.
>         //They can very well be setup later on by the client
>         //- or the client might just not care about them because the dictionaries are
>         //being compiled using an interface such as MgCoordinateSystemDictionaryUtility
>         //- if we throw here, the constructor aborts and the factory constructor aborts as well
>         //for something we can resolve later on (2 reasons described above)
>         SAFE_RELEASE(pEPath);
>
>         m_sDir=L"";
>
>         //internal API value needed for the server's initialization which relies
>         //on the default values being setup automatically
>         m_libraryStatus=lsInitializationFailed;
>     }
>
>
>
> _______________________________________________
> mapguide-internals mailing list
> mapguide-internals at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-internals
>
>   



More information about the mapguide-internals mailing list