Re: [mdr-users] Improved exception handling in NBMDRepositoryImpl.createExtent ?

Martin Matula <[email protected]> Tue, 01 Nov 2005 18:17:02 +0100
Newsgroups gmane.comp.java.netbeans.modules.mdr.user
Message-ID <[email protected]>
You don't need to use a debugger. You just have to use the 
ErrorManager.getDefault().notify(e) (instead of e.printStackTrace()) to 
print out or log the exception. This will print out all the annotations 
of the exception which will include the original exception.
Martin

Pieter Van Gorp wrote:
> Hi, in createExtent(String substName, RefObject metaPackage,
> RefPackage[] existingInstances, String storageId) there is the
> following code:
> <snip source="http://www.netbeans.org/source/browse/mdr/src/org/netbeans/mdr/NBMDRepositoryImpl.java?rev=1.84&content-type=text/vnd.viewcvs-markup">
>        try {
>                 instantiatePackage(substName, null, (MofPackage)
> metaPackage, instancesToCluster, storageId, false);
>             } catch (RuntimeException e) {
>                 throw (CreationFailedException)
> Logger.getDefault().annotate(new CreationFailedException("Cannot
> instantiate package because of unexpected exception: " + e), e);
>             }
> </snip>
> 
> Could this be improved by passing the exception e to the constructor
> of CreationFailedException?  Right now, one has to use a debugger to
> find out at what line the actual e (which is a NPE in my case) occurs
> whereas otherwise the stacktrace would contain all necessary info...
> 
> Best regards,
> --
> Pieter Van Gorp
>        Teaching and Research Assistant
>        FOrmal Techniques in Software engineering (FOTS)
>        University of Antwerp
>        Middelheimlaan 1
>        2020 Antwerpen - Belgium
>        Office: G.304
>        Phone: +32 3 265 38 71
>        Fax: +32 3 265 37 77
>        http://www.fots.ua.ac.be/~pvgorp/research/
>        http://motmot.sourceforge.net/