SlideShare a Scribd company logo
errorhandling techniques in XPages,
    Javascript, Java, Lotusscript and
                         @Formulas
What is error handling?
Errorhandling in:
 ◦@Formula
 ◦Javascript
 ◦Lotusscript
 ◦Java
 ◦xPages

Openlog
Anticipate, detect and process of programming, user and
environment failures or errors

Prevent partially by defensive programming

What counts is what you do with the errors
Error handling in XPages
Error handling in XPages
• Loads of cryptical error messages – no info about triggered
  events
• No central error handling possible - be sparse with your
  @Formulas - use display fields for re-usable calculations
• Defensive programming (@IsError, Test DataTypes:
  @Elements, @IsTime, @IsNumber, @Text ...)
Error handling in XPages
Standard try - catch routine

try {
   // call a function that could error out
   var result = getInvoiceNumbers(customerNumber,invoiceDate);;
}
catch (e) {
    result = "Error in retrieving invoices";
}
// optional use finally runs after the try/catch block
finally {
    window.Forms[0].fldname.value = result
}

Throw your own errors
if (number > 10) { throw "NumberTooHighError" }
Try - catch routine based on error type

try {
   var result = getInvoiceNumbers(customerNumber,invoiceDate);
}
catch (e
   if e == "CustomerNumberException") {
       result = "Incorrect customerNumber";
   }
   else if e == "DateErrorException") {
       result = "Incorrect Date";
   }
   else result = "Error in retrieving invoices";
}
To register a general errorHandler use:

      (window.)onerror=functionname()


This function will have 3 input variables like:
function functionname(msg,url,line_num)


You can use these variables to log/show the error details
Error handling in XPages
◦ use On   Error   blocks
◦                     is a big nono .. you are supposed to
    On Error resume next
  handle things, not ignoring them
◦ You have differtent audiences: users, developers,
  administrators. So throw custom errors.
◦ Then handle specific errors
◦ Option Declare prevents some programmatic errors
◦      Create a template in the new 8.5.1 LS IDE for your error
    new!
    handling blocks in subs and functions
Error handling in XPages
• As with JavaScript use try - catch - finally blocks and
  throw/catch custom errors
Try {
   List list = new ArrayList(getInvoiceNumbers(customerNumber,invoiceD
   ate));
} catch ( IOException e) {
    // handle/log this error
} catch ( OtherErrorException e) {
    // again handle this
} catch (Exception e) {
    // other errors
}
// optional
}finally {
}
• Chose:
  o Handle errors in subfunctions
  o Throw the error back to higher functions


private Integer convertToInteger(String str) {
try {
   Integer intObj2 = Integer.valueOf(str)
   } catch (e) { // do something }
   return int;
}

private Integer convertToInteger(String str) throws
NumberFormatException {
   Integer intObj2 = Integer.valueOf(str)
}
class CustomException extends Exception {
    public CustomException(String msg){
           super(msg);
       }
}

public class Test {

 public static void main(String[] args) {
  try {
    System.out.println(divide(4,0));
  }
    catch (CustomException e) { e.printStackTrace(); }
  }

static int divide(int first,int second) throws CustomException{
   if(second==0) throw new MyException("dividing by zero");
   return first/second;
  }
}
Error handling in XPages
Error handling in xPages
 • Default errorpage on server (admin can change xspnsfxsp.properties)
 • Set errorpage in application
 • Custom Error page (general, debug, specific)
 • Logging to AgentLog
how wonderful, free stuff
•   JavaScript
•   Java
•   XPages
•   Lotusscript




                  DEMO!!!!!!
◦ Getting it to work is NOT ENOUGH!
◦ Always add errorhandling to production code
◦ Thou shall avoid the use of hard coded stuff
◦ When not sure: check
◦ If it can go wrong, it will go wrong. At one point.
◦ Think first, then build your logic
◦ Do not repeat code
◦ Use only one line of code in events (click,
  query*)
◦ Your users are dumb ...
but: you are even dumber (if you ignore them)
◦ Make your code beautiful: comment not what,
  but why and use meaningfull names
Vince Schuurman             Martin Schaefer
vince.schuurman@gmail.com   martin@mschaefer.nl

More Related Content

What's hot (20)

PDF
Mockito intro
Cristian R. Silva
 
PPTX
7.error management and exception handling
Deepak Sharma
 
PDF
Exception handling
Anna Pietras
 
PPT
Exception handling
Raja Sekhar
 
ODP
Unit testing with Easymock
Ürgo Ringo
 
PPTX
Exception handling in java
pooja kumari
 
PPTX
Mockito intro
Jonathan Holloway
 
PPTX
Java exception handling
Md. Tanvir Hossain
 
KEY
Basic Unit Testing with Mockito
Alexander De Leon
 
PPTX
Presentation on-exception-handling
Nahian Ahmed
 
PPT
Exception Handling
backdoor
 
PPT
Types of exceptions
myrajendra
 
PPTX
Exception handling in JAVA
Kunal Singh
 
PPT
Mockito with a hint of PowerMock
Ying Zhang
 
PPTX
Power mock
Piyush Mittal
 
PDF
Mocking in Java with Mockito
Richard Paul
 
PPTX
Exception handling
PhD Research Scholar
 
PPTX
Exception Handling in Java
Ganesh kumar reddy
 
PDF
Java review: try catch
Muzahidul Islam
 
PDF
Java Exception handling
atozknowledge .com
 
Mockito intro
Cristian R. Silva
 
7.error management and exception handling
Deepak Sharma
 
Exception handling
Anna Pietras
 
Exception handling
Raja Sekhar
 
Unit testing with Easymock
Ürgo Ringo
 
Exception handling in java
pooja kumari
 
Mockito intro
Jonathan Holloway
 
Java exception handling
Md. Tanvir Hossain
 
Basic Unit Testing with Mockito
Alexander De Leon
 
Presentation on-exception-handling
Nahian Ahmed
 
Exception Handling
backdoor
 
Types of exceptions
myrajendra
 
Exception handling in JAVA
Kunal Singh
 
Mockito with a hint of PowerMock
Ying Zhang
 
Power mock
Piyush Mittal
 
Mocking in Java with Mockito
Richard Paul
 
Exception handling
PhD Research Scholar
 
Exception Handling in Java
Ganesh kumar reddy
 
Java review: try catch
Muzahidul Islam
 
Java Exception handling
atozknowledge .com
 

Viewers also liked (9)

ODP
Supersize me
dominion
 
PDF
JavaScript and LotusScript - Tricks for Domino Applications
dominion
 
PDF
Oop LotusScript
dominion
 
PDF
Einfach Oop Einfach Handout
dominion
 
PDF
Lotusphere 2007 AD506 Intermediate LotusScript
dominion
 
PDF
ADLotusphere 2007 AD305 APPLICATION DEVELOPMENT WITH IBM LOTUS DOMINO AND IBM...
dominion
 
PDF
Harness the power of XPages in Lotus Domino
dominion
 
PDF
IBM WebSphere Application Server Introduction for Lotus
dominion
 
PDF
I know what you are going to do next summer
dominion
 
Supersize me
dominion
 
JavaScript and LotusScript - Tricks for Domino Applications
dominion
 
Oop LotusScript
dominion
 
Einfach Oop Einfach Handout
dominion
 
Lotusphere 2007 AD506 Intermediate LotusScript
dominion
 
ADLotusphere 2007 AD305 APPLICATION DEVELOPMENT WITH IBM LOTUS DOMINO AND IBM...
dominion
 
Harness the power of XPages in Lotus Domino
dominion
 
IBM WebSphere Application Server Introduction for Lotus
dominion
 
I know what you are going to do next summer
dominion
 
Ad

Similar to Error handling in XPages (20)

PPTX
Training material exceptions v1
Shinu Suresh
 
PPTX
Exception handling in asp.net
Neelesh Shukla
 
PDF
Lecture 9.pdf
SakhilejasonMsibi
 
PDF
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
PPT
ASP.NET 05 - Exception Handling And Validation Controls
Randy Connolly
 
PPT
exceptionvdffhhhccvvvv-handling-in-java.ppt
yjrtytyuu
 
PPTX
Debugging
nicky_walters
 
PPT
exception-handling-in-java.ppt unit 2
thenmozhip8
 
PDF
javaexceptions
Arjun Shanka
 
PDF
Javaexceptions
parthu310
 
PPT
lecture-c-corr-effkkkkkkkkkkkkkp (1).ppt
ZeeshanAli593762
 
PDF
Best Practices in Exception Handling
Lemi Orhan Ergin
 
PPTX
exceptionhandlinginjava-140224181412-phpapp02.pptx
ARUNPRANESHS
 
PPT
Java: Exception
Tareq Hasan
 
PDF
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
NALANDACSCCENTRE
 
PPT
Introduction of exception in vb.net
suraj pandey
 
PPT
JP ASSIGNMENT SERIES PPT.ppt
JAYAPRIYAR7
 
PPT
10 exceptionsin java
APU
 
PPT
unit 4 .ppt
thenmozhip8
 
Training material exceptions v1
Shinu Suresh
 
Exception handling in asp.net
Neelesh Shukla
 
Lecture 9.pdf
SakhilejasonMsibi
 
CS3391 -OOP -UNIT – III NOTES FINAL.pdf
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
ASP.NET 05 - Exception Handling And Validation Controls
Randy Connolly
 
exceptionvdffhhhccvvvv-handling-in-java.ppt
yjrtytyuu
 
Debugging
nicky_walters
 
exception-handling-in-java.ppt unit 2
thenmozhip8
 
javaexceptions
Arjun Shanka
 
Javaexceptions
parthu310
 
lecture-c-corr-effkkkkkkkkkkkkkp (1).ppt
ZeeshanAli593762
 
Best Practices in Exception Handling
Lemi Orhan Ergin
 
exceptionhandlinginjava-140224181412-phpapp02.pptx
ARUNPRANESHS
 
Java: Exception
Tareq Hasan
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
NALANDACSCCENTRE
 
Introduction of exception in vb.net
suraj pandey
 
JP ASSIGNMENT SERIES PPT.ppt
JAYAPRIYAR7
 
10 exceptionsin java
APU
 
unit 4 .ppt
thenmozhip8
 
Ad

More from dominion (20)

PDF
What is a itil and how does it relate to your collaborative environment uklug
dominion
 
PDF
iOS enterprise
dominion
 
PDF
cloud session uklug
dominion
 
ODP
Uklug 2011 administrator development synergy
dominion
 
PDF
Uklug 2011 client management
dominion
 
PDF
JavaScript blast
dominion
 
PDF
Populating your domino directory or any domino database with tivoli directory...
dominion
 
ODP
Uklug2011 Know your Notes
dominion
 
ODP
Quickr
dominion
 
ODP
Taking themes to the next level
dominion
 
ODP
Aussie outback
dominion
 
PDF
Learning to run
dominion
 
PPT
Implementing xpages extension library
dominion
 
PDF
Abb presentation uklug
dominion
 
PDF
Uklug2011.lotus.on.linux.report.technical.edition.v1.0
dominion
 
PPT
Domino testing presentation
dominion
 
PDF
Composite applications tutorial
dominion
 
PDF
Maximizing application performance
dominion
 
PPT
wcm domino
dominion
 
PPT
leverage dxl
dominion
 
What is a itil and how does it relate to your collaborative environment uklug
dominion
 
iOS enterprise
dominion
 
cloud session uklug
dominion
 
Uklug 2011 administrator development synergy
dominion
 
Uklug 2011 client management
dominion
 
JavaScript blast
dominion
 
Populating your domino directory or any domino database with tivoli directory...
dominion
 
Uklug2011 Know your Notes
dominion
 
Quickr
dominion
 
Taking themes to the next level
dominion
 
Aussie outback
dominion
 
Learning to run
dominion
 
Implementing xpages extension library
dominion
 
Abb presentation uklug
dominion
 
Uklug2011.lotus.on.linux.report.technical.edition.v1.0
dominion
 
Domino testing presentation
dominion
 
Composite applications tutorial
dominion
 
Maximizing application performance
dominion
 
wcm domino
dominion
 
leverage dxl
dominion
 

Recently uploaded (20)

PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 

Error handling in XPages

  • 1. errorhandling techniques in XPages, Javascript, Java, Lotusscript and @Formulas
  • 2. What is error handling? Errorhandling in: ◦@Formula ◦Javascript ◦Lotusscript ◦Java ◦xPages Openlog
  • 3. Anticipate, detect and process of programming, user and environment failures or errors Prevent partially by defensive programming What counts is what you do with the errors
  • 6. • Loads of cryptical error messages – no info about triggered events • No central error handling possible - be sparse with your @Formulas - use display fields for re-usable calculations • Defensive programming (@IsError, Test DataTypes: @Elements, @IsTime, @IsNumber, @Text ...)
  • 8. Standard try - catch routine try { // call a function that could error out var result = getInvoiceNumbers(customerNumber,invoiceDate);; } catch (e) { result = "Error in retrieving invoices"; } // optional use finally runs after the try/catch block finally { window.Forms[0].fldname.value = result } Throw your own errors if (number > 10) { throw "NumberTooHighError" }
  • 9. Try - catch routine based on error type try { var result = getInvoiceNumbers(customerNumber,invoiceDate); } catch (e if e == "CustomerNumberException") { result = "Incorrect customerNumber"; } else if e == "DateErrorException") { result = "Incorrect Date"; } else result = "Error in retrieving invoices"; }
  • 10. To register a general errorHandler use: (window.)onerror=functionname() This function will have 3 input variables like: function functionname(msg,url,line_num) You can use these variables to log/show the error details
  • 12. ◦ use On Error blocks ◦ is a big nono .. you are supposed to On Error resume next handle things, not ignoring them ◦ You have differtent audiences: users, developers, administrators. So throw custom errors. ◦ Then handle specific errors ◦ Option Declare prevents some programmatic errors ◦ Create a template in the new 8.5.1 LS IDE for your error new! handling blocks in subs and functions
  • 14. • As with JavaScript use try - catch - finally blocks and throw/catch custom errors Try { List list = new ArrayList(getInvoiceNumbers(customerNumber,invoiceD ate)); } catch ( IOException e) { // handle/log this error } catch ( OtherErrorException e) { // again handle this } catch (Exception e) { // other errors } // optional }finally { }
  • 15. • Chose: o Handle errors in subfunctions o Throw the error back to higher functions private Integer convertToInteger(String str) { try { Integer intObj2 = Integer.valueOf(str) } catch (e) { // do something } return int; } private Integer convertToInteger(String str) throws NumberFormatException { Integer intObj2 = Integer.valueOf(str) }
  • 16. class CustomException extends Exception { public CustomException(String msg){ super(msg); } } public class Test { public static void main(String[] args) { try { System.out.println(divide(4,0)); } catch (CustomException e) { e.printStackTrace(); } } static int divide(int first,int second) throws CustomException{ if(second==0) throw new MyException("dividing by zero"); return first/second; } }
  • 18. Error handling in xPages • Default errorpage on server (admin can change xspnsfxsp.properties) • Set errorpage in application • Custom Error page (general, debug, specific) • Logging to AgentLog
  • 20. JavaScript • Java • XPages • Lotusscript DEMO!!!!!!
  • 21. ◦ Getting it to work is NOT ENOUGH! ◦ Always add errorhandling to production code ◦ Thou shall avoid the use of hard coded stuff ◦ When not sure: check ◦ If it can go wrong, it will go wrong. At one point. ◦ Think first, then build your logic ◦ Do not repeat code ◦ Use only one line of code in events (click, query*) ◦ Your users are dumb ... but: you are even dumber (if you ignore them) ◦ Make your code beautiful: comment not what, but why and use meaningfull names