returnerror
MESSAGE
The returnerror statement passes an error back to the current subroutines calling procedure.
Parameters
This statement has one parameter:
message – is the text of the error message.
Description
The returnerror statement ends the current subroutine immediately and generates an error. If desired, the calling procedure can handle the error with the if error, try or catch statements (see Error Handling. If the calling procedure does not handle the error, Panorama will simply stop the procedure and display the specified error message.
Here is an example procedure which we will call AdjustInventory. It adjusts the inventory level if there are enough items in stock to fulfill the order. If there aren’t enough items in stock, an error message is generated.
if OnHand < parameter(1)
returnerror "Insufficient stock on hand"
endif
OnHand=OnHand-parameter(1)
If this subroutine is called normally, an error message will be displayed if there is not enough stock.
call AdjustInventory,4
call FinishOrder // if there is not enough stock on hand, FinishOrder will not be called
We could revise this program to delete the line item and finish the order if there is not enough stock on hand.
call AdjustInventory,4
if error
call RemoveLineItem
endif
call FinishOrder
With this revision the program will never display an error message for insufficient stock, and the FinishOrder subroutine will always be called.
See Also
- call -- allows a procedure to call a separate procedure within the current database as a subroutine.
- call( -- allows a procedure to be called as a subroutine within a formula and return a result.
- calledby( -- returns true if this function is in code called by the specified database, the specified procedure, or both.
- callingdatabase( -- returns the name of the database that called this procedure as a subroutine, if any.
- callingprocedure( -- returns the name of the procedure that called this procedure as a subroutine, if any.
- callwithin -- allows a procedure to call a mini-procedure within a separate procedure within the current database as a subroutine.
- callwithin( -- allows a "mini-procedure" to be called as a subroutine within a formula and return a result.
- callwithindatabase( -- returns true if the current procedure was called by another procedure in the same database, false if it was called by a procedure in another database.
- catcherror( -- evaluates an expression, but suppresses any error generated by that expression.
- Custom Statements -- creating your own custom statements that can be used in your code.
- Error Handling -- Techniques for trapping runtime errors instead of letting them abort the program.
- Error Wizard -- Advanced dialog for displaying program errors.
- error( -- returns an error with the specified message.
- errortext( -- evaluates an expression, but returns only the error message generated (if any).
- execute -- allows a procedure to call a sequence of statements within the current procedure as a "mini-subroutine".
- execute( -- allows a formula to execute a sequence of statements and return a result.
- executeasap -- executes the specified code at the first possible opportunity, non-atomically.
- executecatcherrors -- is the same as the execute statement, except for the fact that if an error occurs while running, it can be trapped by an if error statement immediately following the executecatcherrors statement.
- executelocal -- is the same as the execute statement, but it shares local variables with the procedure that called it.
- farcall -- allows a procedure to call a separate procedure within a different database as a subroutine.
- farcallwithin -- allows a procedure to call a mini-procedure within a separate procedure in a different database as a subroutine.
- getproceduretext( -- gets the contents (source code) of a procedure.
- info("error") -- returns the most recent error message.
- info("errorparameter") -- returns the parameter that caused a runtime error.
- info("errorstack") -- returns the contents of the procedure stack after an error.
- info("errorstatement") -- returns the name of the statement that Panorama was trying to run at the time an error occurred.
- info("parameters") -- returns the number of parameters passed to a subroutine.
- info("procedurestack") -- returns the contents of Panorama's procedure call stack.
- onerror -- can be used to catch all errors that are not trapped by if error or try statements.
- onfailedresume -- is used to setup a semi-graceful recovery if a resume statement fails because there was no pause statement.
- parameter( -- is used to transfer data between a main procedure and a subroutine.
- parameterentity( -- returns the entity (field or variable) associated with a subroutine parameter, if any.
- return -- ends a subroutine.
- seterror -- changes the error message returned by info("error").
- setparameter -- is used to transfer data from a subroutine back to the main
procedure that called it.
- shortcall -- allows a procedure to call a sequence of statements within the current procedure as a "mini-subroutine".
- throwerror -- causes an immediate error.
History
10.0 | Update | Carried over from Panorama 6.0, but now has two names: RETURNERROR and RTNERROR. Either will work. |