ERROR dialog does not display

Steve_ContrisSteve_Contris Member Posts: 114
I am having a problem getting an error dialog to be shown. I can step right onto the line in the debugger where ERROR is called and the code unit it is called from seems to terminate, but I never see the ERROR dialog. Is this caused by other progress windows that are already being shown? Is there something I should be doing to force it to be processed?
What would Elvis do?

Comments

  • DenSterDenSter Member Posts: 8,305
    That depends on how the error is programmed. If it says ERROR('') then you're never going to see an error box. Put something between the quotes and you should see that pop up.
  • ara3nara3n Member Posts: 9,256
    Also if you running the code with

    If codeunit.run Then
    do this or other,

    you won't see the error. The code is basically capturing the error and
    codeunit.run returns a true or false.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • SobyOneSobyOne Member Posts: 20
    If you have access to the trace functionality, you may need to manually step through the code until it fails.

    The problem can be a statement combination like this:

    INSERT;

    DELETE;

    MODIFY; // FAILURE POINT

    Message('All Done!'); // Error Point

    Why? When no return value is used on database functions, the database operation set is cached and sent to the server as a batch for more efficient processing. If the debugger is not turned on, then the error will be ambiguous.
    _\~ () ]3 `/ () |\| [-
    http://www.SobyLand.com
    651-815-0698
  • AsallaiAsallai Member Posts: 141
    If the Result is empty and not zero, then the process is stopped but nothing is shown.
  • krzychub83krzychub83 Member Posts: 120
    Are You able to put some part of the code? This will help us.
  • Steve_ContrisSteve_Contris Member Posts: 114
    sorry i did not respond sooner for some reason i am not getting email notifications of these postings.

    anyway, here is a snippet showing how ERROR is being called:

    IF EXISTS(TempReqFileName2) THEN
    ERROR( 'A temporary credit card file exists.');

    This line of code is being executed in a codeunit called from a codeunit called from a report, but the codeunit.run is not used. - the codeunit functions are called directly.

    It seems that when ERROR is called here it is only terminating the code unit that it is called from and the message never shows up. Maybe that is just how it works?
    What would Elvis do?
  • krzychub83krzychub83 Member Posts: 120
    I made a simple example to test Your situation. I tried to Run it with couple possibilities, but still it was working very well. Only by using the combination of CU.RUN and IF (Thanks ara3n) I was able to terminate error messages [On whole rout (Report -> CU1 -> CU2 -> CU3) it’s stopped pop ups].

    I know that this is ‘silly’, but try to post an Error from this CU, without any IF condition (maybe on beginning of it). Try to post an error from a higher (sooner) CU, before calling CU.Function()… Move on up, until You see Error pop up. This way You will be able to specify, which CU is responsible for terminating them.
    Good Luck
  • Steve_ContrisSteve_Contris Member Posts: 114
    after my last post i realized that ther is an instance of IF CU.RUN THEN in the mix - I had not seen it before - there are too many levels to this!

    So, that must be what is stopping the messages. If I remove the IF statement and set a local variable with the return value from the CU.RUN statment will that allow the messages?

    I guess I will try that to see. Thanks for the help
    What would Elvis do?
  • BeliasBelias Member Posts: 2,998
    if cu.run then
    //your code
    else
    ERROR('Process Failed');

    ...be sure to see if it is the topmost lvl or you won't get the error anyway
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Steve_ContrisSteve_Contris Member Posts: 114
    grazie belias!

    That should work fine in this case - I would like to get the original message to come up but this is a good enough work-around.
    What would Elvis do?
  • DenSterDenSter Member Posts: 8,305
    Then change it from
    IF Codeunit.RUN THEN...
    
    to this:
    Codeunit.RUN;
    
    That will make the original message come up.
  • Steve_ContrisSteve_Contris Member Posts: 114
    A tried removing the IF statement but the error messages in the code unit being RUN do not come up - they only cause the code unit execution to exit.
    What would Elvis do?
  • DenSterDenSter Member Posts: 8,305
    That seems to be impossible... errors are only suppressed within the IF statement, without it you should see the message.
  • DenSterDenSter Member Posts: 8,305
    Well, maybe there's something like:
    MyBoolean := Codeunit.RUN;
    
    in that case the error is also suppressed.

    Basically:
    If you use the return value of the codeunit it suppresses the error, otherwise you should see the actual message come up.
  • EugeneEugene Member Posts: 309
    for debugging purposes try changing your ERROR(...)
    with IF CONFIRM('error triggered , do you want to terminate transaction ?') THEN ERROR(...)
  • Steve_ContrisSteve_Contris Member Posts: 114
    Assigning the results of the RUN is exactly what was happening. So it is not really the IF as much as it is using the results of the RUN statement that suppresses the error.
    What would Elvis do?
Sign In or Register to comment.