Previous Thread

8/15/2006 7:18:22 PM    Re: How to catch the exception msg in AX
Matt, 
 
Have a look in the Axapta developer's guide for the word 'try'. Or, you can 
 
search the AOT for the words try and catch. 
 
Regards, 
 
Anton 
 
"Matt" <matt1980@foodjam.com> wrote in message 
 
news:O8zMp$HwGHA.1888@TK2MSFTNGP03.phx.gbl...



8/15/2006 11:32:13 PM    How to catch the exception msg in AX
I want to catch the exception msg that thrown to me.. wht is the class or 
 
method for that in C#, we always do in in the following way: 
 
try 
 
{ 
 
//Some code here 
 
} 
 
catch (Exception msg) 
 
{ 
 
MessageBox.Show(msg.Message); 
 
} 
 
how about in X++??

8/16/2006 2:11:17 PM    Re: How to catch the exception msg in AX
anton, cant find any help from the help file 
 
"Matt" <matt1980@foodjam.com> wrote in message 
 
news:O8zMp$HwGHA.1888@TK2MSFTNGP03.phx.gbl...

8/17/2006 6:54:20 PM    Re: How to catch the exception msg in AX
Hi Matt, 
 
You will have to get the message from the infolog. Also consider than zero 
 
or more that one message can be found depending how the exception was throw 
 
and if it was catch and throw again. 
 
static void GetExceptionMessage(Args _args) 
 
{ 
 
int                     infoLines; 
 
SysInfoLogEnumerator            infoLogEnum; 
 
SysInfologMessageStruct         infoMessageStruct; 
 
; 
 
infoLines = infolog.line(); 
 
try 
 
{ 
 
print "before"; 
 
throw error("My Error"); 
 
print "after"; 
 
} 
 
catch(Exception::Error) 
 
{ 
 
infoLogEnum = SysInfoLogEnumerator::newData(infolog.cut(infoLines + 1)); 
 
while(infoLogEnum.moveNext()) 
 
{ 
 
infoMessageStruct = 
 
SysInfologMessageStruct::construct(infoLogEnum.currentMessage()); 
 
print infoMessageStruct.message(); 
 
} 
 
} 
 
pause; 
 
} 
 
-Ricardo Venegas [MSFT] 
 
-- 
 
This posting is provided "AS IS" with no warranties, and confers no rights 
 
"Matt" <matt1980@foodjam.com> wrote in message 
 
news:O8zMp$HwGHA.1888@TK2MSFTNGP03.phx.gbl...