home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxhll.zip / ERROR.REX < prev    next >
OS/2 REXX Batch file  |  1994-02-13  |  2KB  |  68 lines

  1.  
  2.  
  3. /* #include <error.rex> */
  4.  
  5. /**
  6. *** ╔═══════════════════════════════════════════════════════════════════════╗
  7. *** ║ Error Handler                                                         ║
  8. *** ╚═══════════════════════════════════════════════════════════════════════╝
  9. **/
  10.  
  11. Error: procedure
  12.    /**
  13.    ***  This is a centralized processor for error messages and error handling
  14.    **/
  15.  
  16.    parse arg ErrNo,Fatal,String1,String2,String3
  17.  
  18.    /* Select the error string based on the error number */
  19.  
  20.    select
  21.       when ErrNo = 1001 then Msg = "Return code %1 from RxFuncAdd for SQLEXEC"
  22.       when ErrNo = 1002 then Msg = "Return code [%1] from SQLEXEC.  You are probably out-of-storage."
  23.       when ErrNo = 1003 then Msg = "SQL code [%1]: %2"
  24.       when ErrNo = 2002 then Msg = "File '%1' not found."
  25.       when ErrNo = 2003 then Msg = "Directory '%1' doesn't exist."
  26.       when ErrNo = 3000 then Msg = "Urecognized message '%1' passed from message queue."
  27.       when ErrNo = 3001 then Msg = "Error from server: %1."
  28.       when ErrNo = 4000 then Msg = "Host screen doesn't match expected value of '%1'"
  29.       when ErrNo = 5005 then Msg = "Return code 5 from RxQueue. Not a valid queue name: '%1'"
  30.       when ErrNo = 5009 then Msg = "Return code 9 from RxQueue. Queue does not exist: '%1'"
  31.       when ErrNo = 5010 then Msg = "Return code 10 from RxQueue. Queue is busy: '%1'"
  32.       when ErrNo = 5012 then Msg = "Return code 12 from RxQueue. Memory failure on queue: '%1'"
  33.       when ErrNo = 6000 then Msg = "Return code 1000 from RxQueue. Initialization error on queue: '%1'"
  34.  
  35.       when ErrNo = 9999 then Msg = "%1"
  36.       otherwise              Msg = "[%1,%2,%3]"
  37.    end /* select */
  38.  
  39.    /* Render the string with the substituted parameters */
  40.  
  41.    Msg = ErrorRender('%1',String1,Msg)
  42.    Msg = ErrorRender('%2',String2,Msg)
  43.    Msg = ErrorRender('%3',String3,Msg)
  44.  
  45.    /* Determine how to handle the error */
  46.  
  47.    Client = value("CLIENT",,"OS2ENVIRONMENT")
  48.    if Client <> '' then
  49.       call Post Client "status" tag Msg
  50.    say Msg
  51.  
  52.    /* Should we terminate? */
  53.  
  54.    if Fatal then exit ErrNo
  55.    return
  56.  
  57.  
  58. ErrorRender: procedure
  59.  
  60.    parse arg Symbol,SymValue,Line
  61.  
  62.    if pos(Symbol, Line) > 0 then
  63.       do
  64.       parse var Line prefix (Symbol) suffix
  65.       Line = prefix || SymValue || suffix
  66.       end
  67.    return Line
  68.