5 Replies Latest reply on Feb 7, 2015 8:13 AM by philmodjunk

    Error Capture



      Error Capture


      I cant seem to find an error number for Send Mail canceled.  I would like to flag when a user cancels an attempt to send an email from my file.  Currently when an email is canceled and with error capture off an error appears stating " Send Mail has been canceled would you like to continue with this script?" 

      With error capture on, what error message number should I be targeting to capture this error?

        • 1. Re: Error Capture

          Without trying this, I would think that the value returned would be 1 "user canceled action" which is usually what you get when a script pauses on a dialog box (other than show custom dialog) and the user clicks "cancel".

          Sometimes, when I don't know the error code, I get a bit lazy and use:

          If [ Get ( LastError ) ]

          This will cause the IF block to execute for any error code but 0 (no error) returned by this get function.

          You can also use this code to discover an error code:

          Set variable [$Error ; value: Get ( LastError ) ]
          Show Custom Dialog [$Error ]

          And you can use:

          Set Error Capture [on]

           to keep the filemaker generated error from interrupting your script.

          • 2. Re: Error Capture


            Thanks Phil

            I had already tried to use 1 with no luck. I wasn't  aware of the if[Get(LastError)] trick, I may try that but then I risk recording a mail as sent if a different error pops up. 

            I suppose I could add a line to the script  Set variable $$error (get(LastError) and watch the data viewer.  Didn't think of that yesterday  for some reason.  

            Thanks again 

            • 3. Re: Error Capture

              You can also just step through the script in the script debugger, cancel the email and watch for the error code that would then display in the bottom of the debugger.

              • 4. Re: Error Capture

                I used the debugger and it returned 1 as the error code.  Looks like my problem was with location of the line If [Get(LastError)=1].

                had to move it up to just below the send mail line, evidently a beep or pause(.25 seconds in this case) erases the last error code.  Turns out we where both correct to use 1 as the error code.

                Thanks for reminding me the debugger displays error codes, something I had forgot to check.

                • 5. Re: Error Capture

                  Yes, Get ( LastError ) returns the error code only from the immediately previous script step.