|
Exception Handling |
_ERROR — Set to TRUE if there was an exception error.EXTYPE — The exception type number.EXLABEL$ — The location in the code where the exception occurred.EXTEXT$ — A user-friendly description of the exception.SYSTEXT$ — The underlying operating system’s description of the exception (if any).EXCEPTIONTYPE — Given an exception name (case-insensitive), returns the exception type number. If an unknown exception name
literal is given, a compile-time error is posted -- Unknown exception name.
Any casing works: "DIVBY0", "divby0", and "DivBy0" are all equivalent.EXCEPTIONNAME$ — Given an EXTYPE, returns the exception name.
Returns a null string if there is no matching exception name.
When handling multiple exception types, SELECT CASE provides
a clean and readable way to check which exception occurred. Instead of
chaining multiple IF / ELSE IF statements, you can use
SELECT CASE with the EXTYPE function to handle
different exceptions appropriately.
You can handle similar exceptions together by listing multiple
exception types in a single CASE statement.
Some exceptions fall into numeric ranges. You can use
CASE IS to handle them efficiently.
When execution enters a WHEN EXCEPTION block (both
ATTACHED and DETACHED), Sheerpower snapshots the current
routine call depth. If an exception occurs anywhere inside the
protected region, the runtime rewinds all routine calls to that saved
depth before transferring control to the handler. Because Sheerpower uses
a stackless calling model (no traditional call stack), this rewind
is extremely fast.
WHEN EXCEPTION ... USE, Sheerpower snapshots the
protected region’s routine depth. If an exception occurs, all
deeper routine calls are discarded (later restored for RETRY/CONTINUE) before the
USE handler runs.RETRY: Restores the saved routine depth and
re-executes the original failing statement -- usually after adjusting
the values that caused the exception.CONTINUE: Restores the saved routine depth and
resumes with the first statement after the one that failed.WHEN EXCEPTION; use RETRY for targeted fixes or
CONTINUE to move on, skipping the failing statement.
If an exception occurs and no matching WHEN EXCEPTION handler
is present in the current block, Sheerpower automatically bubbles up
the exception to the next higher-level handler in the call stack.
This means the system searches for a broader handler in the calling routine
or main program. If no handler is found anywhere, the program stops and
displays an exception message describing the error, its type, and the
source location (via EXLABEL$ and EXTEXT$).
WHEN EXCEPTION block.WHEN EXCEPTION block near the top level of your program
to ensure all unexpected errors are caught gracefully.
The CAUSE EXCEPTION statement lets you generate an exception
deliberately when specific conditions occur. This is useful for enforcing
input validation, custom error logic, or consistent error signaling between
routines.
CAUSE EXCEPTION exception_number
Example output:
CAUSE EXCEPTION forces the specified exception number to occur
as though the runtime system had generated it.
The exception_number may be any integer expression.
When executed, Sheerpower immediately raises that exception, invoking
any active WHEN EXCEPTION handler or bubbling upward until
a handler is found.
CAUSE EXCEPTION with
a specific number that your handler recognizes.CAUSE EXCEPTION to enforce
program rules and simplify validation logic.
The following table lists all Sheerpower internal exception names, their exception type (EXTYPE) , and descriptive text (EXTEXT$). Sorted alphabetically by exception name for quick reference.
| EXNAME | EXTYPE | EXTEXT$ |
|---|---|---|
| ALREADYOPEN | -7011 | Must close table before reusing table name |
| AMBSYMDEF | -10007 | Ambiguous symbol definition |
| ANGLE00 | 3008 | Evaluation of ANGLE(0,0) not supported |
| ARS_KEY_NOT_FOUND | -7019 | Internal ARS key number not found |
| ASSERTION_FAILED | -11003 | Assertion failed |
| BADACOS | 3007 | Argument to ACOS or ASIN not in range -1<=X<=1 |
| BADATTR | -4026 | Invalid attribute |
| BADBASE | -4002 | Numeric base in DECODE/ENCODE$ not between 2 and 36 |
| BADCHAIN | 10005 | Chained program unavailable |
| BADCHANNEL | 7001 | Bad channel number |
| BADCHARPTR | 4009 | Bad CHAR* pointer |
| BADDATFILE | -7004 | Error processing data file (!XL !XL) |
| BADDBMS | -7008 | Unknown DBMS in table file |
| BADDECODE | -4001 | Bad number encountered in DECODE argument |
| BADDEFFILE | -7003 | Error processing data dictionary (!XL !XL) |
| BADDIALOG | -4031 | Invalid input dialogbox format |
| BADDIRNAME | -7012 | Error in directory name |
| BADEXNAME | -4034 | Unknown exception name |
| BADFIELD | -8001 | Field not found |
| BADFIELD_OUTSIDE | -8006 | Field is outside of the record size |
| BADFILEATTRIB | 7100 | Invalid file attribute |
| BADFILENAME | 7120 | Illegal file name |
| BADFILINP | 8105 | Invalid file input |
| BADFORMAT | 8201 | Format is invalid |
| BADKEYMAP | -4025 | Bad keymap information |
| BADMEMADDR | -4008 | Illegal memory address to MEM function |
| BADMENU | -4023 | Invalid input menu format |
| BADOCCUR | -8005 | No such field occurrence |
| BADONIDX | 10001 | ON index out of range |
| BADREDIM | 6005 | REDIM first index greater than second |
| BADSCREEN | -4007 | Invalid input screen format |
| BADSETMARGIN | 4006 | SET MARGIN value less than zonewidth |
| BADSETZONE | 4007 | SET ZONEWIDTH value greater than margin |
| BADSTRFILE | -7002 | Invalid table file format |
| BADTMO | 8402 | Illegal numeric value for time-expression |
| BADTTYINP | 8102 | Input format not recognized |
| BAD_MB | -5210 | Bad Megabyte Specification |
| BAD_VAL_OPTIONS | 1005 | Bad VAL options |
| BLTOVF | 1003 | Overflow in evaluating numeric-supplied-function |
| CHANNELINUSE | 7003 | Channel number already in use |
| CVTERROR | -8002 | Data conversion error |
| DBNOSUP | -4028 | Database engine doesn't support this feature |
| DBREQPW | -4030 | Data base engine requires a password |
| DEADLOCK | -7014 | Deadlock detected |
| DEBUGCODE | 233 | Debug code not allowed in compiled images |
| DIVBY0 | 3001 | Division by zero |
| DUPKEY | -7009 | Key already exists in this context |
| DYNDTPMISMATCH | -3101 | Datatype mismatch |
| EOFINP | 8011 | End of file on input |
| EXDISKQUOTA | -8004 | Disk quota exceeded |
| EXPECTEDSIMPLEVAR | -7020 | Expected a simple variable |
| EXPNEGNONINT | 3002 | Negative number used as base in non-integral power |
| EXPRINVALID | -4017 | Expression or statement invalid |
| EXPZERONEG | 3003 | Zero raised to negative power |
| EXTERR | -10003 | Called routine got an error |
| FATSETSYM | -10006 | Setting symbol failed |
| FILEERROR | -7001 | Error in file operation (!AS) (!XL) |
| FILEFULL | -7010 | File or table is full |
| FILELOCKED | 7112 | File locked or protected |
| FILENOTFOUND | 7110 | File not found |
| FILENOTOPEN | 7004 | File not open |
| FILETMO | -7016 | Timeout on file access |
| FLOATOVF | 1002 | Floating overflow |
| ILLARG2DATE$ | -4004 | DATE$() second argument specifies unknown format |
| ILLARG2FULLTIME$ | -4032 | FULLTIME$() second argument specifies unknown format |
| ILLARGCHARSET$ | -4010 | Illegal argument to CHARSET$() |
| ILLARGCHR | 4002 | Illegal argument to CHR$() |
| ILLARGDATE$ | -4004 | Illegal number of days |
| ILLARGENCODE$ | -4009 | Illegal argument to ENCODE$() |
| ILLARGFULLTIME$ | -4018 | Illegal number of seconds |
| ILLARGORD | 4003 | Illegal argument to ORD() |
| ILLARGORDNAME$ | -4003 | Illegal argument to ORDNAME$() |
| ILLARGRPT | 4010 | Second argument to REPEAT$ < 0 |
| ILLARGSECONDS | -4019 | Illegal fulltime format |
| ILLARGSIZ | 4004 | Illegal argument to SIZE |
| ILLARGTAB | 4005 | Index in TAB less than one |
| ILLARGVAL | 4001 | Illegal argument to VAL() |
| ILLDATEFORMAT | -4005 | Illegal date format |
| ILLFILTER | -4022 | Illegal filter |
| ILLLENARG | -4016 | Illegal length argument |
| ILLNUM | 1001 | Illegal number |
| ILLPASMECH | -10001 | Illegal passing mechanism for datatype |
| ILLPATTERN | -4020 | Illegal pattern |
| ILLPROCESS | -4101 | Illegal process name |
| ILLSORTSEP | -4033 | SORT$() seperator must not be a null string |
| ILLSYMNAM | -10005 | Illegal symbol name |
| ILLVRULE | -4021 | Illegal validation rule |
| INPTMO | 8401 | Timeout on input |
| INTEG_FAIL | -7015 | Database engine rejected add or update |
| INTERR | 1002 | Integer overflow |
| INTERRUPTED | -1001 | Program interrupted |
| LBOUNDERR | 4008 | Lower bound index out of range |
| LOG0ORNEG | 3004 | LOG() of zero or negative number |
| MISSING_MAILTO | -11002 | MAILTO address is missing |
| NEED_POSITIVE_YEAR | -4040 | Year must be positive |
| NEVER_EXTRACTED | -7022 | A COLLECT/EXTRACT must precede a FOR EACH statement |
| NOACCESS | -7005 | Privilege or security level insufficient for database operation |
| NOACCESSDB | -4029 | Database engine connection unavailable |
| NOACCESS_OS | -7030 | Privilege or security level insufficient for OS operation |
| NOCURREC | 7305 | No current record |
| NODISPATCH | -10004 | Dispatch routine not found |
| NOEXRTN | -10002 | External routine not accessible |
| NOEXTRACT | -7018 | A COLLECT/EXTRACT has yet to been done to RECOLLECT/REEXTRACT from |
| NOMEMORY | -5002 | Exceeded available memory |
| NONNUMINP | 8103 | Non-numeric input when number expected |
| NORECORD | -7006 | Record not found |
| NOSUCHSTR | -4015 | String doesn't name an existing table |
| NOT0OR1 | -4006 | Logical values must be either 0 (false) or 1 (true) |
| NOTAKEY | -7007 | Field specified is not a key field |
| NOTALLOWED | 7322 | This feature is not allowed in the safe programming environment |
| NOTCHANNEL0 | 7002 | Channel zero cannot be closed |
| NUMINPOVF | 1007 | Number too big on input |
| OUTOFDATA | 8001 | Out of DATA |
| PARTONLYCH | -7017 | PARTIAL only allowed for character fields |
| PROGRAM_TIMEOUT | -11004 | Program exceeded its timeout setting |
| PUTFAILED | -7007 | Record PUT failed when trying to fetch a new record |
| READNOTNUMBER | 8101 | Number expected in READ |
| READNUMOVF | 1006 | Numeric overflow in READ |
| READSTROVF | 1053 | String overflow in READ |
| READSYNERR | -8102 | Syntax error in DATA |
| RECEXCEDED | 8301 | Record size exceeds maximum allowed (RECSIZE) |
| REDIMOVF | 5001 | REDIM overflow |
| RETNOGOSUB | 10002 | RETURN without GOSUB |
| SARYCORRUPT | -4012 | Saved window data is corrupted |
| SARYNOCRT | -4013 | Saved window restoration requires CRT terminal |
| SARYVERSIONMISMATCH | -4011 | Saved window can't be restored by this SheerPower |
| SELNOMATCH | 10004 | SELECT found no matching CASE |
| SOURCECHANGED | -1002 | Program edited, but not saved or replaced |
| SPRINTF_FORMAT | -8200 | SPRINTF$() format error |
| SQRTNEG | 3005 | Square root of negative number |
| STRIDCORRUPT | -4014 | Table ID corrupt |
| STRING_LENGTHS_MUST_MATCH | -8008 | String lengths must match |
| STROVF | 1051 | String too long |
| STROVFINP | 1054 | String too long on input |
| SUBOUTBND | 2001 | Subscript out of bounds |
| TOOFEWDATA | 8012 | Too few data items in record |
| TOOFEWINP | 8002 | Too few input items |
| TOOMANYDATA | 8013 | Too many data items in record |
| TOOMANYFILES | 7101 | Too many files open |
| TOOMANYINP | 8003 | Too many input items |
| TOO_FEW_ARGS | -3006 | Too few arguments |
| TOO_MANY_ARGS | -3005 | Too many arguments |
| TOO_MANY_MACROS | -10005 | Too many or recursive macros |
| TRIED_TO_CHANGE_A_KEY | -7021 | This key field cannot be modified |
| UBOUNDERR | 4009 | Upper bound index out of range |
| UNKSESSION | -11001 | Unknown or invalid session |
| UNK_KS_VALUE | -4024 | Unknown keystroke value |
| UNSUPDATA | -8003 | Unsupported field datatype |
| UNTERMINATED_COMMENT | -10008 | Unterminated inline comment |
| UPDATEKEY | -7013 | Key fields cannot be updated |
| VALOVF | 1004 | Overflow in evaluating VAL |
| WRONGOWNSET | -4027 | Set ownership mismatch |
| ZEROMOD | 3006 | MOD() or REMAINDER() had a zero divisor |
|
Hide Description
|
|
|
Enter or modify the code below, and then click on RUN |
|
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |