AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MapException Message

1 REPLY 1
Reply
Message 1 of 2
Anonymous
546 Views, 1 Reply

MapException Message

Hi all,
I recently came across DotNet samples of Map 3d 2011.
I’m talking about Topology samples.
How I can catch errors code of  Map with error  message correctly in Dot.NET?
In autolisp I make with functions for handling error messages begin with ade_err:
ade_errmsg, ade_errcode ....

Dot.Net:

try
{
     // Do something……………………..
}
catch(MapException ex)
{

    Utility.AcadEditor.WriteMessage("\nERROR: --------");
}

MapException not represented error message correctly.
Thanks!

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: Anonymous

MapException has properties like Message, InnerException, ErrorCode...

 

When handling exception, if you only want to show error message, you can

 

try

{

...

}

catch(MapException ex)

{

    theEditor.WriteMessage("\nERROR: " + ex.Message)

}

 

You need to be aware, in many cases, the Exception thrown by AutoCAD Map is an exception object that is derived from MapException, such as MapImportExportException. Sometimes you want to go down into the InnerException:

 

theEditor.WriteMessage("\nError: " + e.InnerException.Message)

 

It all depends on what the operation the code is doing and what possible type of exception the code could be raising... You may want to use multiple catch{} clause to catch different type of exception and handle them accordingly, fromo the most concrete type to most generic type. For example, in your very complicated Importing/Exporting process:

 

try

{

    ...

}

catch(MapImortExportException imexEx)

{

...

}

catch(MapException mex)

{

...

}

catch(Autodesk,AutoCAD.Runtime.Exception aex)

{

..

}

catch(System.Exception ex)

{

//handle all other exceptiones other than the 3 exceptions being caugth in above catch{} clauses

...

}

 

Of course, if you do not embed huge, complicated process in the try{} block, you may not need that complicated multiple catch{}

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost