arno
11/14/2005 5:40:00 PM
Hi Mike,
Thanks for your answer.
The idea is to centralize exception in a global repository. (an axapta table
with a custom app to read them)
The advantages are to have a better view of the application's problems, and
to not wait to be notified before correcting a bug.
So, I need the description of the 'exception' to log it ...
Is there an infologLine for all the exceptions ?
For example, If I compute a divide by zero operation, there's nothing in the
Infolog ...
What about exception thrown by classes that are executed on the server (AOS)
?
Thanks,
arno
"Mike Frank" <mifra@nospam.de> wrote in message
news:%23%23CnIyS6FHA.3636@TK2MSFTNGP09.phx.gbl...
> As a starting point you have to understand, that Axapta has no "real"
> Exceptions. The notion of an Exception (class) is not known in Axapta.
> With the standard handling all "exception" messages are written to the
> infolog. That's where you can get those messages from and that's where you
> have to delete them, if you want to replace the standard messages with
> your own.
>
> Below is an example how you could do that. Be aware, that the way the
> infolog contents are read is a very simplistic approach, that will not
> work in a real world scenario. All standard checking procedures will put
> some warning messages into the infolog and then a final line, saying that
> the process was aborted. So you would have to consider all lines. The
> infolog container holds two entries for every infolog line (one with an
> enum for the level (info, warning, error) and another with the actual
> message. The message line itself will contain possible prefixes. This you
> could process with the help of the SysInfologItem class.
>
> All depends on what you want to do. The best way is to run with standard
> behaviour wherever it is possible.
>
> int logpoint;
> container infologCon;
> ;
> info("Before");
>
> try
> {
> logpoint = infolog.line();
>
> throw error("Forced error");
> }
> catch (Exception::Error)
> {
> // get the contents of the infolog
> infologCon = infolog.copy(logpoint + 1, infolog.line());
>
> // delete handled messages from infolog
> infolog.cut(logpoint + 1, infolog.line());
>
> // put your own message in
> info(strfmt("The following error was found: %1",
> conlen(infologCon) >= 2 ? strrem(conpeek(infologCon, 2), '\t') : ''));
> }
>