Скачать презентацию
Идет загрузка презентации. Пожалуйста, подождите
Презентация была опубликована 10 лет назад пользователемМихаил Чурин
1 Structured Error Handling in the ABL Sarah Marshall QA Architect, OpenEdge Session 128
2 © 2009 Progress Software Corporation. All rights reserved. Traditional Error Handling 2 NO-ERROR ON ERROR UNDO, LEAVE RETURN ERROR
3 © 2009 Progress Software Corporation. All rights reserved. A Bit About Blocks
4 © 2009 Progress Software Corporation. All rights reserved. UNDO, ON ERROR RETRY NEXT LEAVE RETURN A Bit About Blocks 4 Outer Block Inner Block
5 © 2009 Progress Software Corporation. All rights reserved. UNDO, ON ERROR RETRY NEXT LEAVE RETURN A Bit About Blocks 5 Outer Block Inner Block E
6 © 2009 Progress Software Corporation. All rights reserved. UNDO, ON ERROR RETRY NEXT LEAVE RETURN A Bit About Blocks 6 Outer Block Inner Block E
7 © 2009 Progress Software Corporation. All rights reserved. CATCH err AS Progress.Lang.Error Structured Error Handling Model – 10.1C 7 CATCH blocks to handle all error types myError INHERITS Progress.Lang.AppError Ability to create user-defined application errors Facilities to propagate errors up the call stack UNDO, THROW
8 © 2009 Progress Software Corporation. All rights reserved. ON ERROR UNDO, RETRY NEXT LEAVE RETURN Catching Errors 8 Enclosing Block Associated Block E Catch
9 © 2009 Progress Software Corporation. All rights reserved. ON ERROR UNDO, RETRY NEXT LEAVE RETURN Catching Errors 9 Enclosing Block Associated Block E Catch
10 © 2009 Progress Software Corporation. All rights reserved. ON ERROR UNDO, RETRY NEXT LEAVE RETURN Catching Errors 10 Enclosing Block Associated Block Catch E
11 © 2009 Progress Software Corporation. All rights reserved. PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = CATCH e AS Progress.Lang.SysError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE OBJECT e. END CATCH. END. END PROCEDURE. Lets Look At The Code 11
12 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 12 PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = CATCH e AS Progress.Lang.SysError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE OBJECT e. END CATCH. END. END PROCEDURE.
13 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 13 PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = CATCH e AS Progress.Lang.SysError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE OBJECT e. END CATCH. END. END PROCEDURE.
14 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 14 PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = CATCH e AS Progress.Lang.SysError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE OBJECT e. END CATCH. END. END PROCEDURE.
15 © 2009 Progress Software Corporation. All rights reserved. Object Hierarchy 15 Progress.Lang.Object Progress.Lang.ProError Progress.Lang.AppError Progress.Lang.SysError Progress.Lang. SoapFaultError User-Defined Error Objects Progress.Lang. Error >
16 © 2009 Progress Software Corporation. All rights reserved. Object Hierarchy 16 Progress.Lang.Object Progress.Lang.ProError Progress.Lang.AppError Progress.Lang.SysError Progress.Lang. SoapFaultError User-Defined Error Objects Progress.Lang. Error >
17 © 2009 Progress Software Corporation. All rights reserved. Object Hierarchy 17 Progress.Lang.Object Progress.Lang.ProError Progress.Lang.AppError Progress.Lang.SysError Progress.Lang. SoapFaultError User-Defined Error Objects Progress.Lang. Error >
18 © 2009 Progress Software Corporation. All rights reserved. Object Hierarchy 18 Progress.Lang.Object Progress.Lang.ProError Progress.Lang.AppError Progress.Lang.SysError Progress.Lang. SoapFaultError User-Defined Error Objects Progress.Lang. Error >
19 © 2009 Progress Software Corporation. All rights reserved. Progress.Lang. Error > Object Hierarchy 19 Progress.Lang.Object Progress.Lang.ProError Progress.Lang.AppError Progress.Lang.SysError Progress.Lang. SoapFaultError User-Defined Error Objects
20 © 2009 Progress Software Corporation. All rights reserved. Error Objects 20 NumMessages, Severity, CallStack Properties available on ProError GetMessage(), GetMessageNum() Methods available on ProError AddMessage(), RemoveMessage() ReturnValue Additional Methods and Properties on AppError
21 © 2009 Progress Software Corporation. All rights reserved. ON ERROR UNDO, RETRY LEAVE NEXT RETURN Throwing Errors 21 Enclosing Block Associated Block E
22 © 2009 Progress Software Corporation. All rights reserved. ON ERROR UNDO, RETRY LEAVE NEXT RETURN Throwing Errors 22 THROW Enclosing Block Associated Block E
23 © 2009 Progress Software Corporation. All rights reserved. Enclosing Block Associated Block E ON ERROR UNDO, RETRY LEAVE NEXT RETURN Throwing Errors 23 THROW
24 © 2009 Progress Software Corporation. All rights reserved. Enclosing Block Associated Block ON ERROR UNDO, RETRY LEAVE NEXT RETURN Throwing Errors 24 E THROW
25 © 2009 Progress Software Corporation. All rights reserved. Throwing Errors 25 ROUTINE-LEVEL ON ERROR UNDO, THROW Overrides default ON ERROR of routine level blocks UNDO, THROW Explicitly throws (or re-throws) an error
26 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 26 PROCEDURE ErrorBlock: FOR EACH Customer ON ERROR UNDO, LEAVE: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN MESSAGE ERROR-STATUS:GET-MESSAGE(1). END. END PROCEDURE.
27 © 2009 Progress Software Corporation. All rights reserved. PROCEDURE ErrorBlock: FOR EACH Customer ON ERROR UNDO, LEAVE: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN MESSAGE ERROR-STATUS:GET-MESSAGE(1). END. END PROCEDURE. Lets Look At The Code 27
28 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 28 ROUTINE-LEVEL ON ERROR UNDO, THROW. PROCEDURE ErrorBlock: FOR EACH Customer ON ERROR UNDO, THROW: FIND FIRST Order WHERE Order-Num = END. END PROCEDURE.
29 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 29 ROUTINE-LEVEL ON ERROR UNDO, THROW. PROCEDURE ErrorBlock: FOR EACH Customer ON ERROR UNDO, THROW: FIND FIRST Order WHERE Order-Num = END. END PROCEDURE.
30 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 30 ROUTINE-LEVEL ON ERROR UNDO, THROW. PROCEDURE ErrorBlock: FOR EACH Customer ON ERROR UNDO, THROW: FIND FIRST Order WHERE Order-Num = END. END PROCEDURE.
31 © 2009 Progress Software Corporation. All rights reserved. RETURN ERROR Returning Errors 31 Enclosing Block Associated Block E
32 © 2009 Progress Software Corporation. All rights reserved. Returning Errors 32 Caller Enclosing Block Associated Block E
33 © 2009 Progress Software Corporation. All rights reserved. Returning Errors 33 Caller Enclosing Block Associated Block E
34 © 2009 Progress Software Corporation. All rights reserved. Returning Errors 34 Caller Enclosing Block Associated Block E
35 © 2009 Progress Software Corporation. All rights reserved. Returning Errors 35 RETURN ERROR [error string] Return a Progress.Lang.AppError with error string RETURN ERROR Returns error of type error-object with
36 © 2009 Progress Software Corporation. All rights reserved. Returning Errors 36 RETURN ERROR [error string] Return a Progress.Lang.AppError with error string RETURN ERROR Returns error of type error-object with Cannot return an error object from the AppServer
37 © 2009 Progress Software Corporation. All rights reserved. PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN RETURN ERROR NEW OrdNotFoundError(1001). END. END PROCEDURE. Lets Look At The Code 37
38 © 2009 Progress Software Corporation. All rights reserved. PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN RETURN ERROR NEW OrdNotFoundError(1001). END. END PROCEDURE. Lets Look At The Code 38
39 © 2009 Progress Software Corporation. All rights reserved. /* MAIN.P */ RUN ErrorBlock IN hPersProc. CATCH e AS Progress.Lang.AppError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE e. END CATCH. PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN RETURN ERROR NEW OrdNotFoundError(1001). END. END PROCEDURE. Lets Look At The Code 39
40 © 2009 Progress Software Corporation. All rights reserved. /* MAIN.P */ RUN ErrorBlock IN hPersProc. CATCH e AS Progress.Lang.AppError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE e. END CATCH. PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN RETURN ERROR NEW OrdNotFoundError(1001). END. END PROCEDURE. Lets Look At The Code 40
41 © 2009 Progress Software Corporation. All rights reserved. A Few Words About NO-ERROR NO-ERROR Continues to suppress errors at the statement level
42 © 2009 Progress Software Corporation. All rights reserved. A Few Words About NO-ERROR NO-ERROR Continues to suppress errors at the statement level NO-ERROR Can handle errors raised via UNDO, THROW
43 © 2009 Progress Software Corporation. All rights reserved. A Few Words About NO-ERROR 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
44 © 2009 Progress Software Corporation. All rights reserved. What That Means Is… 44 NO-ERROR ON ERROR, UNDO CATCH RETURN ERROR UNDO, THROW ERROR condition
45 © 2009 Progress Software Corporation. All rights reserved. What That Means Is… 45 NO-ERROR ON ERROR, UNDO CATCH RETURN ERROR UNDO, THROW ERROR condition Generate any error
46 © 2009 Progress Software Corporation. All rights reserved. What That Means Is… 46 NO-ERROR ON ERROR, UNDO CATCH RETURN ERROR UNDO, THROW ERROR condition Generate any error Handle any error
47 © 2009 Progress Software Corporation. All rights reserved. And FINALLY… 47 Enclosing Block Associated Block
48 © 2009 Progress Software Corporation. All rights reserved. And FINALLY… 48 Enclosing Block Catch Associated Block
49 © 2009 Progress Software Corporation. All rights reserved. And FINALLY… 49 Always executes on success or failure Enclosing Block Catch Finally Associated Block
50 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 50 PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = CATCH e AS Progress.Lang.SysError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE OBJECT e. END CATCH. FINALLY: /* clean up code */ END FINALLY. END. END PROCEDURE.
51 © 2009 Progress Software Corporation. All rights reserved. Lets Look At The Code 51 PROCEDURE ErrorBlock: FOR EACH Customer: FIND FIRST Order WHERE Order-Num = CATCH e AS Progress.Lang.SysError: MESSAGE e:GetMessage(1) VIEW-AS ALERT-BOX. DELETE OBJECT e. END CATCH. FINALLY: /* clean up code */ END FINALLY. END. END PROCEDURE.
52 © 2009 Progress Software Corporation. All rights reserved. In Summary Uniform model for handling error conditions More flexibility for application specific errors Traditional and structured error handling models co-exist
53 Structured Error Handling in the ABL Sarah Marshall QA Architect, OpenEdge Session 128
Еще похожие презентации в нашем архиве:
© 2024 MyShared Inc.
All rights reserved.