© 2005 Wellesley Information Services. All rights reserved. Error Handling in LotusScript Agents Chuck Connell CHC-3 Consulting.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Error HandlingPHPMay-2007 : [#] PHP Error Handling.
Detecting Bugs Using Assertions Ben Scribner. Defining the Problem  Bugs exist  Unexpected errors happen Hardware failures Loss of data Data may exist.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
CSI 3120, Exception handling, page 1 Exception and Event Handling Credits Robert W. Sebesta, Concepts of Programming Languages, 8 th ed., 2007 Dr. Nathalie.
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
VBA Modules, Functions, Variables, and Constants
Debugging CPSC 315 – Programming Studio Fall 2008.
Chapter 11 Exception Handling and Event Handling.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
1 Exception and Event Handling (Based on:Concepts of Programming Languages, 8 th edition, by Robert W. Sebesta, 2007)
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
Apply Sub Procedures/Methods and User Defined Functions
JavaScript Form Validation
Principles of Secure Account Management By Chuck Connell
PZ11A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ11A - Exception handling Programming Language Design.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
PHP meets MySQL.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
PHP Workshop ‹#› PHP Error Handling. PHP Workshop ‹#› Types There are 12 unique error types, which can be grouped into 3 main categories: Informational.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
Exceptions Handling the unexpected. RHS – SWC 2 The Real World So far, most of our code has been somewhat näive We have assumed that nothing goes wrong…
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
1 Software Construction and Evolution - CSSE 375 Exception Handling - Principles Steve Chenoweth, RHIT Above – Exception handling on the ENIAC. From
Introduction to Exception Handling and Defensive Programming.
Web User Controls This presentation will cover the basics of defining, creating and using a web user control. Presented to Twin Cities.NET user group By.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
EIW - ASP Introduction1 Active Server Pages VBScript.
Dynamic Debug Output and Error Handling in CF5 and CFMX November 12, 2002 By Douglas M. Smith Application Architect for Teratech, Inc.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Handling Exceptions. 2 home back first prev next last What Will I Learn? Describe several advantages of including exception handling code in PL/SQL Describe.
What is Programming? Computer programming is about telling the computer what it is we want it to do We tell the computer what we want it to do by sending.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
PHP Error Handling Section :I Source: 1.
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
Matthew Glenn AP2 Techno for Tanzania This presentation will cover the different utilities on a computer.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Lecture 7 Conditional Scripting and Importing/Exporting.
Controlling Program Flow with Decision Structures.
Java Programming: Exceptions1 Exceptions Reference: java.sun.com/docs/books/tutorial/essential/exceptions/
Exceptions Lecture 11 COMP 401, Fall /25/2014.
JavaScript and Ajax (Control Structures) Week 4 Web site:
IMS 3253: Validation and Errors 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Validation and Error Handling Validation.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Programming with Visual Basic.NET. Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons.
Introduction to Exceptions in Java CS201, SW Development Methods.
1 Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Testing and delivery Web design principles. Web development is software development.
Eighth Lecture Exception Handling in Java
Generics, Exceptions and Undo Command
VBA - Excel VBA is Visual Basic for Applications
Logger, Assert and Invariants
Error Handling Summary of the next few pages: Error Handling Cursors.
Web Programming– UFCFB Lecture 17
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
TEMPDB – INTERNALS AND USAGE
Exception Handling Imran Rashid CTO at ManiWeber Technologies.
Exception and Event Handling
Presentation transcript:

© 2005 Wellesley Information Services. All rights reserved. Error Handling in LotusScript Agents Chuck Connell CHC-3 Consulting

2 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript (LS) Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

3 Why This Matters Topics covered apply to all scripting situations  Pull-down actions, buttons, form/view buttons  Form/view/database event triggers  Periodic/nightly agents Admins need accurate and clear error reporting from server agents  Often have a lot to review each morning  Hard to diagnose cryptic errors in the server log  Must know when something goes wrong, and just what the problem is  Worst thing is not knowing there is a problem

4 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

5 Principles of Good Error Handling Catch errors as early as possible  Design-time is better than code-time  Compile-time is better than test-time  Testing is better than production  Catching errors earlier is cheaper and faster Report meaningful error messages  Tell the user what is really wrong  Suggest how to fix the problem Make full use of language’s error mechanisms  LotusScript gives you many such tools  We will show most during this talk

6 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

7 Compile Time, Option Declare Option Declare is the single most important line in any LotusScript code  Forces all variables to be declared  Put it in the Options code section (object)  Catches many errors immediately  It is OFF by default, should be ON  However, developers can change the default in the Programmer’s Pane properties box

8 Compile Time, Option Declare (cont.) Declare Agent Demo

9 Compile Time, Explicit Data Types Variables default to Variant type  Convenient, since Variants can be almost anything  Also dangerous, since Variants can be almost anything  Solution is to put an explicit type on all Dim statements Notes:  Only small number of situations where Variant is really needed  Can use suffix chars for typing #, %, !), but hard to read and remember

10 Compile Time, Explicit Data Types (cont.) True Type Agent Demo

11 Compile Time, Constants Use of constants for embedded text and numbers is SOP for all programming languages Somehow, LotusScript programmers often overlook this basic principle Why is it related to error handling?  If you don’t do it, you will have hard-to-find errors Suppose there are 10,000 lines of code; you want to change the view name

12 Compile Time, Constants (cont.) Code Sample: Constants

13 Compile Time, Soft Field Names This topic is similar to using constants, except the constants are Notes field names  Even programmers who use regular constants often overlook this application Benefit is the same as string/number constants  When you want to change a field name (very common), it is much easier this way Suppose there are 100 references to many different field names, and you want to change them Code sample, named “Soft Fields”

14 Compile Time, Soft Field Names (cont.) Code Sample: Soft Fields

15 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

16 Runtime, Check Notes Objects Whenever you work with a Notes object, make sure it really exists This coding mistake leads to errors that are tough to find  The line with the runtime error is often far from the line with the coding error

17 Compile Time, Check Notes Objects (cont.) We cause runtime error by changing Tim’s name What line trips the runtime error reporting? Code Sample: Check Objects Bad

18 Compile Time, Check Notes Objects (cont.) Any missing object is reported immediately Code Sample: Check Objects Good

19 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

20 LS Error Handlers, Theory When LS encounters a runtime error, it looks for a local user-defined error handler for that error code If no local handler is found, LS looks for one in the calling procedure, then the next up calling procedure, etc. If none are found, LS calls a simple built-in handler, then exits So how do you create an error handler…?  Tell LS what error handler to use for each error code  Create the error handler routines

21 Error Handlers – Sample Tells LS what to do with an error  On Error Goto ErrorReturn  Which errors? All of them  What to do? Go to ErrorReturn label

22 Error Handlers – Sample (cont.) Set up error handler  Block of code from ErrorReturn to Exit Sub  Notice the Err, Error$, and Erl variables – defined within error handlers  Notice the Resume statement – means that error handling is done You don’t need an error handler in every routine  Can allow LS to “fail up” to a higher-level routine  This is often good software design

23 Error Handlers – Sample (cont.) Code Sample: Error Handler

24 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

25 Special Error Handlers Sometimes, an LS runtime error is not really an error  You don’t want to exit or fail Code sample, named Special Errors  On Error DIR_ERROR Resume Next  Means: “For just error code 76, keep processing”  Test by renaming the temp file Other points  To get the relevant error code, you usually have to print it out  Second general On Error erases the special instructions

26 What We’ll Cover … Looking at the general principles of good software error handling Identifying compile-time error detection in LotusScript Understanding runtime error detection and reporting in LS Setting up error handlers in LS Dealing with special-case errors in LS Using an error log file in LS for periodic agents

27 Notes Error Log So, all this looks nice interactively… But what about nightly agents?  Print statements from periodic agents are written to server log file  These are tough to find in the morning

28 Notes Error Log (cont.) How about a special log file for periodic agents? Code sample, named Error Log  We will look at each line  Log file uses ALOG4NTF template  Code uses NotesLog class  LogAction vs LogError  Handles timestamps, error codes, and messages Can anyone see a problem with this code?

29 Notes Error Log, Caution Suppose your code has a runtime error before the error log is set up For industrial-strength code  Create a temporary “print” handler at the start  Then switch to the log handler after it is created

30 Resources Domino Designer 6 Help / Contents / LotusScript / Error Processing Full scripts for all samples are on conference CD On my Web site 

31 7 Key Points to Take Home Scan code for good LS error handling Are database, view, and field names soft-coded at the top? Is there an On Error statement near the top? Do early database and view opens have an immediate validity check? Do you see Option Declare? If this is a periodic server agent, do you see the NotesLog class? Insist on error handling for all server-based Agents

32 Your Turn! How to Contact Me: Chuck Connell