从 OpenEdge UI 触发器向主程序抛出错误

Throw an error from an OpenEdge UI trigger to the main program

我正在努力将系统错误对象从 UI 触发器传播到主程序。

  ON CHOOSE OF btnButton IN FRAME frmFrame
  DO:

     /* this will cause a system error */
     FIND FIRST Customer NO-LOCK
          WHERE Customer.CustNum = 1875918759178.

     CATCH eErr AS Progress.Lang.SysError:
        /* It does get caught over here */
        UNDO, THROW eErr.
     END CATCH.
  END.

  CATCH eMain AS Progress.Lang.SysError:
     /* this message doesn't happen */
     MESSAGE
        "caught"
        VIEW-AS ALERT-BOX.
  END CATCH.

虽然它似乎不想传播错误对象。有什么想法吗?

尝试在 FIND 语句的末尾使用 NO-ERROR:

FIND FIRST Customer NO-LOCK
      WHERE Customer.CustNum = 1875918759178 NO-ERROR.

然后可以使用ERROR-STATUS系统句柄来捕获错误:

MESSAGE ERROR-STATUS:ERROR SKIP
        ERROR-STATUS:GET-MESSAGE(1)
        VIEW-AS ALERT-BOX.

应该设置该错误状态,直到某些其他语句以 NO-ERROR 执行。您还可以使用 AVAILABLE(Customer) 查看是否找到记录:

MESSAGE AVAILABLE(Customer) VIEW-AS ALERT-BOX.

来自关于 THROW 选项的文档,撤消语句:

"UNDO, THROW is not allowed in a CATCH block of a user interface trigger. The ABL does not you to raise or RETURN error out of a user interface trigger. To do so will result in a compile-time error. " 上面这句话说"Does not you to..."我相信应该是"does not allow you to"。但是文档本身是错误的。

无论如何,截至今天(2016 年 12 月 27 日),您想要完成的事情似乎还不可能。