Options

How to retrieve run-time error?

denvitdenvit Member Posts: 12
All expert guys

I would like to make a log table which contain run-time error log when error occur during runtime. For example when user use dataport to import invalid format, an error occured then write to error log table.

Comments

  • Options
    kinekine Member Posts: 12,562
    It is very hard work to do that, because you have no tool for catching error within C/SIDE... you can use some external library which will detect the error window, read the text and save it... I think that there is some posts about component, which is able to read the error message and close the error window. Search for it... it can be good start for you...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    WaldoWaldo Member Posts: 3,412
    In the Timer-dll from Navision, there is an event "OnTimerError" or something like that. The message parameter contains the message.

    This is off course only useful when using the timer :-/

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    denvitdenvit Member Posts: 12
    First of All,
    I wanna say thank you to both of you for your help. =D>

    Waldo, Could you please show me a little example to use Navision Timer to catch an error message ? :idea:
  • Options
    WaldoWaldo Member Posts: 3,412
    Well, actually, it's just useful when you have to use the timer for one reason or another. Not the other way around ... .

    Else, it would be a bit of "dirty coding", i think. Something like this:

    OnRun()
    intInterval := 1000; // 1 second
    myTimer.Interval := intInterval;
    myTimer.Enabled := TRUE;

    myTimer::Timer(Milliseconds : Integer)
    myTimer.Enable := FALSE;
    ExecuteMyCode;

    myTimer::TimerError(ErrorString : Text[1024])
    WriteLog(ErrorString);

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    DenSterDenSter Member Posts: 8,304
    Isn't that event meant to catch an error raised by the timer itself? Wouldn't it be kind of silly to create a timer event just to catch the errors caused by that timer?

    Or does that event catch errors caused elsewhere in the system?
  • Options
    WaldoWaldo Member Posts: 3,412
    I knew I would have to explain this ... .

    First: I don't use it this way at all.
    Second: It catches errors during the proces initiated by the timer event. (At least, it does in my NAS Service, don't know for sure it will when you don't use a NAS).

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    DenSterDenSter Member Posts: 8,304
    ok cool, another one to investigate its potential, thanks :).
  • Options
    jreynoldsjreynolds Member Posts: 175
    When you do this with a GUI client (that is, not NAS) then the user gets the error message box where he/she must click OK to proceed. After dealing with the message box the TimerError event runs.
  • Options
    WaldoWaldo Member Posts: 3,412
    hm, then I guess this is not an option.

    Sorry for this ...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    kinekine Member Posts: 12,562
    Or you can use external component to "click" the OK button on the error message (someone created it - I saw it somewhere there...) :-) but it is only workaround...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    Peter_WijntjesPeter_Wijntjes Member Posts: 28
    Why do we accept this kind of behaviour from Navision anyway?

    It would be so nice to have simple Exception Handling available within Navision.

    for example
    if NOT CodeUnit.RUN then
    NavGetLastError()
    <would be great >

    How about using this community as a vehicle to directly address Navision Development at Microsoft regarding this (and possible other) issue(s)?

    :-k
    Peter Wijntjes
    MBS NAV Consultant
  • Options
    DenSterDenSter Member Posts: 8,304
    pwijntjes wrote:
    Why do we accept this kind of behaviour from Navision anyway?
    Do we have a choice?
  • Options
    kinekine Member Posts: 12,562
    I posted this issue 1,5 year back... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    WaldoWaldo Member Posts: 3,412
    Accept it,

    Nothing is going to change about the development environment or whatsoever.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    DenSterDenSter Member Posts: 8,304
    I think error handling is on the top of all Navision developers. I know I used to mention it to anyone from Navision that came into our office, I mentioned it when I visited Denmark, and now I mention it every time when I speak to any MS Navision person. If I end up at the MS summit this year I will mention it again to anyone who will listen.

    I have mentioned it so many times without results I have lost all faith that it will ever happen in C/AL. Once we get the big C# interface we're all rooting for, it'll be different. Untill then we'll have to keep debugging.
  • Options
    WaldoWaldo Member Posts: 3,412
    You mention a lot :wink: .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    DenSterDenSter Member Posts: 8,304
    I want to be known as 'The Great Mentioner' 8-[
  • Options
    ara3nara3n Member Posts: 9,255
    Waldo
    you mentioned that nothing will change in development environment, but in 4.0 SP1 they've added 3 new function to the API. FINDFIRST,FINDLAST,FINDRECORSET
    I can still hope they'll add just something new in there.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    DenSterDenSter Member Posts: 8,304
    I wonder if those 'new' functions are anything like FIND('-'), FIND('+') and FIND('='). Wait a minute.... we already HAVE those... :-k
  • Options
    kinekine Member Posts: 12,562
    Yes, we have, but it seems that they will be optimized for usage with MS SQL...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    madhuri.sysmadhuri.sys Member Posts: 13
    How can i get exact error Text and Error Numbers from such type of Example??
    for example
    if NOT CodeUnit.RUN then
    NavGetLastError()
    <would be great >

    what i have to do in NavGetLastError() ????
  • Options
    kinekine Member Posts: 12,562
    It was example, what will be nice to have in some next release of Navision... it is not real example of working code...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.