DEV-8: Structured Error Handling in the ABL - PowerPoint PPT Presentation

About This Presentation
Title:

DEV-8: Structured Error Handling in the ABL

Description:

RETRY. NEXT. LEAVE. RETURN. A Bit About Blocks. Outer Block. Inner Block ... RETRY. LEAVE. NEXT. RETURN. Throwing Errors. Enclosing Block. Associated Block. E. THROW ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 33
Provided by: prod62
Category:

less

Transcript and Presenter's Notes

Title: DEV-8: Structured Error Handling in the ABL


1
DEV-8 Structured Error Handling in the ABL
Sarah Marshall
QA Architect
2
Structured Error Handling -- Agenda
  • Overview of the old and new
  • Catching errors
  • Raising errors
  • The FINALLY block
  • Changes to be aware of

3
Traditional Error Handling Model
  • Behavior handled at the statement level

NO-ERROR / ERROR-STATUS
Behavior handled locally at the block level
ON ERROR, UNDO LEAVE RETRY
Application can return error to its caller
RETURN ERROR error string
4
Traditional Error Handling Model
Failure cases handled in varied and inconsistent
ways
Errors must be handled locally, do not propagate
automatically
No way to add additional information to
application errors
5
A Bit About Blocks
6
A Bit About Blocks
Outer Block
ON ERROR RETRY NEXT LEAVE RETURN
UNDO,
Inner Block
7
A Bit About Blocks
Outer Block
ON ERROR RETRY NEXT LEAVE RETURN
UNDO,
Inner Block
E
8
Structured Error Handling Model 10.1C
  • CATCH blocks to handle all error types

CATCH err AS Progress.Lang.Error
Ability to create user-defined application errors
myError INHERITS Progress.Lang.AppError
Facilities to propagate errors up the call stack
UNDO, THROW lterror objectgt
9
Lets look at the code
PROCEDURE ErrorBlock FOR EACH Customer ON
ERROR UNDO, LEAVE FIND FIRST Order WHERE
Order-Num 1001 NO-ERROR. IF
ERROR-STATUSERROR THEN MESSAGE
ERROR-STATUSGET-MESSAGE(1). FIND FIRST
Order WHERE Order-Num 1002. END. END
PROCEDURE.
10
Catching Errors
Enclosing Block
ON ERROR UNDO, RETRY NEXT LEAVE RETURN
Associated Block
Catch
E
11
Lets look at the code
PROCEDURE ErrorBlock FOR EACH Customer
FIND FIRST Order WHERE Order-Num 1001.
CATCH e AS Progress.Lang.SysError MESSAGE
eGetMessage(1) VIEW-AS ALERT-BOX. DELETE
OBJECT e. END CATCH. END. END PROCEDURE.
12
Object Hierarchy
Progress.Lang.Object
Progress.Lang. Error ltltinterfacegtgt
Progress.Lang.ProError
Progress.Lang.SysError
Progress.Lang.AppError
Progress.Lang. SoapFaultError
User-Defined Error Objects
13
Error Objects
Properties available on ProError
NumMessages, Severity, CallStack
Methods available on ProError
GetMessage(), GetMessageNum()
Additional Methods and Properties on AppError
AddMessage(), RemoveMessage() ReturnValue
14
Throwing Errors
Enclosing Block
ON ERROR UNDO, RETRY LEAVE NEXT RETURN
Associated Block
E
THROW
15
Throwing Errors
Overrides default ON ERROR of routine level blocks
ROUTINE-LEVEL ON ERROR UNDO, THROW
Explicitly throws (or re-throws) an error
UNDO, THROW lterror objectgt
16
Lets look at the code
PROCEDURE ErrorBlock FOR EACH Customer ON
ERROR UNDO, LEAVE FIND FIRST Order WHERE
Order-Num 1001 NO-ERROR. IF
ERROR-STATUSERROR THEN MESSAGE
ERROR-STATUSGET-MESSAGE(1). END. END
PROCEDURE.
17
Lets look at the code
ROUTINE-LEVEL ON ERROR UNDO, THROW. PROCEDURE
ErrorBlock FOR EACH Customer ON ERROR UNDO,
THROW FIND FIRST Order WHERE Order-Num
1001. END. END PROCEDURE.
18
Returning Errors
Enclosing Block
Caller
Associated Block
RETURN ERROR
E
19
Returning Errors
Return a Progress.Lang.AppError with error string
RETURN ERROR error string
Returns error of type error-object with
RETURN ERROR lterror objectgt
20
Lets look at the code
/ MAIN.P / RUN ErrorBlock IN hPersProc.
CATCH e AS Progress.Lang.AppError MESSAGE
eGetMessage(1) VIEW-AS ALERT-BOX. DELETE e.
END CATCH.
PROCEDURE ErrorBlock FOR EACH Customer ON
ERROR UNDO, LEAVE FIND FIRST Order WHERE
Order-Num 1001 NO-ERROR. IF
ERROR-STATUSERROR THEN RETURN ERROR NEW
OrdNotFoundError(1001). END. END PROCEDURE.
21
A Few Words About NO-ERROR
Continues to suppress errors at the statement
level
NO-ERROR
Can handle errors raised via UNDO, THROW
NO-ERROR
Converts information from error objects to
ERROR-STATUS
NO-ERROR
22
What that means is
Handle any error
NO-ERROR DO ON ERROR CATCH
Generate any error
RETURN ERROR UNDO, THROW ERROR condition
23
And FINALLY
Enclosing Block
Always executes on success or failure
Associated Block
Catch
Finally
24
Lets look at the code
PROCEDURE ErrorBlock FOR EACH Customer
FIND FIRST Order WHERE Order-Num 1001.
CATCH e AS Progress.Lang.SysError MESSAGE
eGetMessage(1) VIEW-AS ALERT-BOX. DELETE
OBJECT e. END CATCH. FINALLY /
clean up code / END FINALLY. END. END
PROCEDURE.
25
Change in Behavior
  • With traditional error handling

Does Not Raise Error
hSrvCONNECT()NO-ERROR. IF ERROR-STATUSNUM-MESSA
GES gt 0 THEN MESSAGE Connect Failed! VIEW-AS
ALERT-BOX.
Raises Error
With structured error handling
hSrvCONNECT(). CATCH err AS Progress.Lang.SysErr
or END CATCH.
26
What About User-defined Functions?
Q Will RETURN ERROR in a udf raise error
in the caller?
A No.
Q Is there another way to raise error
from a udf?
A YES!
27
Raising Error from User-defined Functions
  • With RETURN ERROR

Does Not Raise Error in Caller
FUNCTION foo RETURNS INTEGER () RETURN
ERROR. END FUNCTION.
Raises Error in Caller
With structured error handling
FUNCTION foo RETURNS INTEGER () UNDO, THROW
NEW AcmeError(). END FUNCTION.
28
In Summary
  • Uniform model for handling error conditions
  • More flexibility for application specific errors
  • Traditional and structured error handling models
    co-exist

29
Related Presentations
  • DEV-12 Whats New in the Object-Oriented ABL
  • DEV-22 Catch Me If You Can Practical Structured
    Error Handling
  • DEV-32 Using the Advanced GUI, Structured Error
    Handling and SonicMQ to Build Semi-Disconnected
    Point of Sales

30
?
Questions
31
Thank You
32
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com