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

Hugues Wisniewski hugues.wisniewski at autodesk.com
Fri Apr 24 13:51:49 EDT 2009


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
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;
    }





More information about the mapguide-internals mailing list