home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxhll.zip
/
ERROR.REX
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-02-13
|
2KB
|
68 lines
/* #include <error.rex> */
/**
*** ╔═══════════════════════════════════════════════════════════════════════╗
*** ║ Error Handler ║
*** ╚═══════════════════════════════════════════════════════════════════════╝
**/
Error: procedure
/**
*** This is a centralized processor for error messages and error handling
**/
parse arg ErrNo,Fatal,String1,String2,String3
/* Select the error string based on the error number */
select
when ErrNo = 1001 then Msg = "Return code %1 from RxFuncAdd for SQLEXEC"
when ErrNo = 1002 then Msg = "Return code [%1] from SQLEXEC. You are probably out-of-storage."
when ErrNo = 1003 then Msg = "SQL code [%1]: %2"
when ErrNo = 2002 then Msg = "File '%1' not found."
when ErrNo = 2003 then Msg = "Directory '%1' doesn't exist."
when ErrNo = 3000 then Msg = "Urecognized message '%1' passed from message queue."
when ErrNo = 3001 then Msg = "Error from server: %1."
when ErrNo = 4000 then Msg = "Host screen doesn't match expected value of '%1'"
when ErrNo = 5005 then Msg = "Return code 5 from RxQueue. Not a valid queue name: '%1'"
when ErrNo = 5009 then Msg = "Return code 9 from RxQueue. Queue does not exist: '%1'"
when ErrNo = 5010 then Msg = "Return code 10 from RxQueue. Queue is busy: '%1'"
when ErrNo = 5012 then Msg = "Return code 12 from RxQueue. Memory failure on queue: '%1'"
when ErrNo = 6000 then Msg = "Return code 1000 from RxQueue. Initialization error on queue: '%1'"
when ErrNo = 9999 then Msg = "%1"
otherwise Msg = "[%1,%2,%3]"
end /* select */
/* Render the string with the substituted parameters */
Msg = ErrorRender('%1',String1,Msg)
Msg = ErrorRender('%2',String2,Msg)
Msg = ErrorRender('%3',String3,Msg)
/* Determine how to handle the error */
Client = value("CLIENT",,"OS2ENVIRONMENT")
if Client <> '' then
call Post Client "status" tag Msg
say Msg
/* Should we terminate? */
if Fatal then exit ErrNo
return
ErrorRender: procedure
parse arg Symbol,SymValue,Line
if pos(Symbol, Line) > 0 then
do
parse var Line prefix (Symbol) suffix
Line = prefix || SymValue || suffix
end
return Line