A5: Structured Error Handling in the ABL Phillip Malone Senior Technical Support Engineer.

Slides:



Advertisements
Similar presentations
Exception Handling The purpose of exception handling is to permit the program to catch and handle errors rather than letting the error occur and suffer.
Advertisements

CS102--Object Oriented Programming
Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
© The McGraw-Hill Companies, 2006 Chapter 15. © The McGraw-Hill Companies, 2006 Exceptions an exception is an event that occurs during the life of a program.
Jerry Lebowitz. Topics  Provides a facility for a systematic object oriented approach to handling runtime errors ◦ Can also handle runtime errors.
OpenEdge® Object-oriented ABL
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Java Exceptions, Cloning, Serialization Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
交通大學資訊工程學系 Programming in Java Exception Handling again 蔡文能 交通大學資訊工程學系
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
交通大學資訊工程學系 Programming in Java Exception Handling 蔡文能 交通大學資訊工程學系
Exceptions David Rabinowitz. March 3rd, 2004 Object Oriented Design Course 2 The Role of Exceptions Definition: a method succeeds if it terminates in.
Exceptions. 2 Objectives Introduce C# exception handling –library exception types –custom exceptions Describe keywords used for exception handling –try.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Exception Error handling. Exception 4 n An unusual occurrence during program execution that requires immediate handling n Errors are the most common type.
1 Web Based Programming Section 6 James King 12 August 2003.
Chapter 11 Exception Handling F Exceptions and Exception Types F Claiming Exceptions F Throwing Exceptions F Catching Exceptions F Rethrowing Exceptions.
Chapter 13, Slide 1 Exception Handling Exception handling is a language feature that allows the programmer to handle runtime "exceptional conditions."
1 Chapter Eight Exception Handling. 2 Objectives Learn about exceptions and the Exception class How to purposely generate a SystemException Learn about.
Object Oriented Programming
CIS 270—Application Development II Chapter 13—Exception Handling.
Exception Handling in Java Exception Handling Introduction: After completing this chapter, you will be able to comprehend the nature and kinds.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
COMPUTER PROGRAMMING 2 Exceptions. What are Exceptions? Unexpected events that happen when the code is executing (during runtime). Exceptions are types.
Pemrograman VisualMinggu …12… Page 1 MINGGU Ke Duabelas Pemrograman Visual Pokok Bahasan: Exception Handling Tujuan Instruksional Khusus: Mahasiswa dapat.
Module 12 Handling Errors in T-SQL Code. Module Overview Understanding T-SQL Error Handling Implementing T-SQL Error Handling Implementing Structured.
© 2009 Progress Software Corporation 1 Click to Edit Master Subtitle Style Overview of OpenEdge® GUI for.NET Release 10.2A Jarmo Nieminen Senior Technical.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
DEV-12: Object-oriented Programming in OpenEdge® ABL
Introduction to Exception Handling and Defensive Programming.
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
INT-5: Integrate over the Web with OpenEdge® Web Services
Catch Me If You Can P ractical Structured Error Handling Peter van Dam.
HANDLING EXCEPTIONS Chapter 9. Outline  Learn about the limitations of traditional error-handling methods  Throw exceptions  Use try blocks  Catch.
COP4020 Programming Languages Exception Handling Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
ICS 313: Programming Language Theory Chapter 14: Exceptions.
DEV-6: Advanced Object-Oriented Programming in the ABL Evan Bleicher Senior Development Manager Shelley Chase
CSE 332: C++ Statements C++ Statements In C++ statements are basic units of execution –Each ends with ; (can use expressions to compute values) –Statements.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
Exceptions in Java. What is an exception? An exception is an error condition that changes the normal flow of control in a program Exceptions in Java separates.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
Copyright  Oracle Corporation, All rights reserved. 23 Handling Exceptions.
Java Programming: Exceptions1 Exceptions Reference: java.sun.com/docs/books/tutorial/essential/exceptions/
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Peter Judge A8: What’s New in Object-Oriented ABL Principal Software Engineer OpenEdge 10.1C and beyond.
Introduction to Exceptions in Java CS201, SW Development Methods.
1 Handling Errors and Exceptions Chapter 6. 2 Objectives You will be able to: 1. Use the try, catch, and finally statements to handle exceptions. 2. Raise.
© 2001 by Ashby M. Woolf Revision 2 Exceptions for Exceptional Circumstances Passing a Problem up the Chain of Command.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Lecture 11 Dr. Eng. Ibrahim El-Nahry Exception Handling.
Java Expert Session By: Prof. Mehul Raval Prof. Adarsh Patel Prof. Mihir Suthar.
Lec.11 (Chapter 11) Exception Jiang (Jen) ZHENG July 13 th, 2005.
Exceptions Error Handling and Recovery
similar concepts, different syntax
DEV-12: What’s New in Object-Oriented ABL
On transactions, and Atomic Operations
DEV-4: Structured Error Handling in the ABL
Chapter 13 Exception Handling
Exception Handling Chapter 9 Edited by JJ.
Exception Handling In Text: Chapter 14.
Part B – Structured Exception Handling
Programming in C# Lesson 5. Exceptions..
Exception Handling Imran Rashid CTO at ManiWeber Technologies.
Exception Handling.
Presentation transcript:

A5: Structured Error Handling in the ABL Phillip Malone Senior Technical Support Engineer

© 2008 Progress Software Corporation 2 Structured Error Handling -- Agenda  Overview of the old and new  Catching errors  Raising errors  The FINALLY block  Changes to be aware of

© 2008 Progress Software Corporation 3 NO-ERROR / ERROR-STATUS Traditional Error Handling Model Behavior handled at the statement level ON ERROR, UNDO { LEAVE | RETRY | …} Behavior handled locally at the block level RETURN ERROR [error string] Application can return error to its caller

© 2008 Progress Software Corporation 4 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 Traditional Error Handling Model

© 2008 Progress Software Corporation 5 A Bit About Blocks

© 2008 Progress Software Corporation 6 UNDO, ON ERROR RETRY NEXT LEAVE RETURN A Bit About Blocks Outer Block Inner Block

© 2008 Progress Software Corporation 7 UNDO, ON ERROR RETRY NEXT LEAVE RETURN A Bit About Blocks Outer Block Inner Block E

© 2008 Progress Software Corporation 8 CATCH err AS Progress.Lang.Error Structured Error Handling Model – 10.1C 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

© 2008 Progress Software Corporation 9 Let’s look at the code 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). FIND FIRST Order WHERE Order-Num = END. END PROCEDURE.

© 2008 Progress Software Corporation 10 ON ERROR UNDO, RETRY NEXT LEAVE RETURN Catching Errors Enclosing Block Associated Block Catch E

© 2008 Progress Software Corporation 11 Let’s look at the code 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.

© 2008 Progress Software Corporation 12 Object Hierarchy Progress.Lang.Object Progress.Lang.ProError Progress.Lang.AppError Progress.Lang.SysError Progress.Lang. SoapFaultError User-Defined Error Objects Progress.Lang. Error >

© 2008 Progress Software Corporation 13 Error Objects NumMessages, Severity, CallStack Properties available on ProError GetMessage(), GetMessageNum() Methods available on ProError AddMessage(), RemoveMessage() ReturnValue Additional Methods and Properties on AppError

© 2008 Progress Software Corporation 14 ON ERROR UNDO, RETRY LEAVE NEXT RETURN Throwing Errors Enclosing Block Associated Block E THROW

© 2008 Progress Software Corporation 15 Throwing Errors ROUTINE-LEVEL ON ERROR UNDO, THROW Overrides default ON ERROR of routine level blocks UNDO, THROW Explicitly throws (or re-throws) an error

© 2008 Progress Software Corporation 16 Let’s look at the code 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.

© 2008 Progress Software Corporation 17 Let’s 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 = END. END PROCEDURE.

© 2008 Progress Software Corporation 18 Caller Enclosing Block Returning Errors Associated Block E RETURN ERROR

© 2008 Progress Software Corporation 19 Returning Errors RETURN ERROR [error string] Return a Progress.Lang.AppError with error string RETURN ERROR Returns error of type error-object with

© 2008 Progress Software Corporation 20 /* 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 ON ERROR UNDO, LEAVE: FIND FIRST Order WHERE Order-Num = 1001 NO-ERROR. IF ERROR-STATUS:ERROR THEN RETURN ERROR NEW OrdNotFoundError(“1001”). END. END PROCEDURE. Let’s look at the code

© 2008 Progress Software Corporation 21 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

© 2008 Progress Software Corporation 22 What that means is… NO-ERROR DO ON ERROR CATCH RETURN ERROR UNDO, THROW ERROR condition Generate any error Handle any error

© 2008 Progress Software Corporation 23 Enclosing Block Finally Catch Associated Block And FINALLY… Always executes on success or failure

© 2008 Progress Software Corporation 24 Let’s look at the code 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.

© 2008 Progress Software Corporation 25 hSrv:CONNECT(…)NO-ERROR. IF ERROR-STATUS:NUM-MESSAGES > 0 THEN: MESSAGE “Connect Failed!” VIEW-AS ALERT-BOX. Change in Behavior With traditional error handling… hSrv:CONNECT(…). CATCH err AS Progress.Lang.SysError: … END CATCH. With structured error handling… Does Not Raise Error Raises Error

© 2008 Progress Software Corporation 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!

© 2008 Progress Software Corporation 27 FUNCTION foo RETURNS INTEGER (): RETURN ERROR. END FUNCTION. Raising Error from User-defined Functions With RETURN ERROR… FUNCTION foo RETURNS INTEGER (): UNDO, THROW NEW AcmeError(). END FUNCTION. With structured error handling… Does Not Raise Error in Caller Raises Error in Caller

© 2008 Progress Software Corporation 28 In Summary  Uniform model for handling error conditions  More flexibility for application specific errors  Traditional and structured error handling models co-exist

© 2008 Progress Software Corporation 29 Related Presentations DEV-12 What’s 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

© 2008 Progress Software Corporation 30 Questions ?

© 2008 Progress Software Corporation 31 Thank You

© 2008 Progress Software Corporation 32