Navigation:  Macros > Macro Language > Built-in Functions > All Functions (Alphabetical) >


Previous pageReturn to chapter overviewNext page

void = RaiseError(sMessage, bAbortScript)


Use the RaiseError macro function to generate your own error messages during the execution of a Macro. This is a void function which means that you do not need to assign the result of this function to any variable. This function takes 2 parameters :



This is the text that will appear in the error message, whether it is simply a run-time message, or it causes the script to abort.


If the value of bAbortScript is set to false then the failure of this assertion will simply abort the current macro and generate a run-time message which will be displayed in the Messages Window during diary generation. If the value of bAbortScript is set to true then the failure of this assertion will abort the current script and display a modal message with the context of the error (see example below).




Note that you do not need to include a lot of context information in sMessage because Q++Studio automatically appends to your message detailed information about the context in which the error was generated : the page number, the date of the token, the token being evaluated, and the origin of that token. The origin of the token may be different than the token itself, if tokens are used recursively. In the example above, the current token is [a4*5d], but one sees that actually this token came from the evaluation of the [4*1*5d] token. The origin is the exact text that is in your GridTemplate.


The RaiseError function is most useful when there are many possibilities that are addressed in code and you want an error if none of these is followed. Example :


 switch nWeekdayNumber

         case 1..5

                 // do weekday stuff

         case 6..7

                 // do weekend stuff


                 RaiseError(nWeekdayNumber is not in range of 1-7', true)



Otherwise, if you only want to verify that a unique basic assumtion is true, then he most convenient way to make use of the RaiseError features is through an Assertion. If you want a run-time message to be generated, without causing any error condition, then use the LogMessage function.

Topic 174290 updated on 03-May-2018.
Topic URL: https://www.qppstudio.net/webhelp/index.html?raiseerror.htm