SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
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
• 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 ...)
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
◦ 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
• 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
 • 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

Mais conteúdo relacionado

Mais procurados

7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handlingDeepak Sharma
 
Exception handling
Exception handlingException handling
Exception handlingAnna Pietras
 
Exception handling
Exception handlingException handling
Exception handlingRaja Sekhar
 
Unit testing with Easymock
Unit testing with EasymockUnit testing with Easymock
Unit testing with EasymockÜrgo Ringo
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javapooja kumari
 
Basic Unit Testing with Mockito
Basic Unit Testing with MockitoBasic Unit Testing with Mockito
Basic Unit Testing with MockitoAlexander De Leon
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handlingNahian Ahmed
 
Exception Handling
Exception HandlingException Handling
Exception Handlingbackdoor
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptionsmyrajendra
 
Exception handling in JAVA
Exception handling in JAVAException handling in JAVA
Exception handling in JAVAKunal Singh
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMockYing Zhang
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with MockitoRichard Paul
 

Mais procurados (20)

Mockito intro
Mockito introMockito intro
Mockito intro
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception handling
Exception handlingException handling
Exception handling
 
Unit testing with Easymock
Unit testing with EasymockUnit testing with Easymock
Unit testing with Easymock
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Mockito intro
Mockito introMockito intro
Mockito intro
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Basic Unit Testing with Mockito
Basic Unit Testing with MockitoBasic Unit Testing with Mockito
Basic Unit Testing with Mockito
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Exception Handling
Exception HandlingException Handling
Exception Handling
 
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
 
Exception handling in JAVA
Exception handling in JAVAException handling in JAVA
Exception handling in JAVA
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
Power mock
Power mockPower mock
Power mock
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
 
Exception handling
Exception handlingException handling
Exception handling
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Java review: try catch
Java review: try catchJava review: try catch
Java review: try catch
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 

Destaque

Supersize me
Supersize meSupersize me
Supersize medominion
 
JavaScript and LotusScript - Tricks for Domino Applications
JavaScript and LotusScript - Tricks for Domino ApplicationsJavaScript and LotusScript - Tricks for Domino Applications
JavaScript and LotusScript - Tricks for Domino Applicationsdominion
 
Oop LotusScript
Oop LotusScriptOop LotusScript
Oop LotusScriptdominion
 
Einfach Oop Einfach Handout
Einfach Oop Einfach HandoutEinfach Oop Einfach Handout
Einfach Oop Einfach Handoutdominion
 
Lotusphere 2007 AD506 Intermediate LotusScript
Lotusphere 2007 AD506 Intermediate LotusScriptLotusphere 2007 AD506 Intermediate LotusScript
Lotusphere 2007 AD506 Intermediate LotusScriptdominion
 
ADLotusphere 2007 AD305 APPLICATION DEVELOPMENT WITH IBM LOTUS DOMINO AND IBM...
ADLotusphere 2007 AD305 APPLICATION DEVELOPMENT WITH IBM LOTUS DOMINO AND IBM...ADLotusphere 2007 AD305 APPLICATION DEVELOPMENT WITH IBM LOTUS DOMINO AND IBM...
ADLotusphere 2007 AD305 APPLICATION DEVELOPMENT WITH IBM LOTUS DOMINO AND IBM...dominion
 
Harness the power of XPages in Lotus Domino
Harness the power of XPages in Lotus DominoHarness the power of XPages in Lotus Domino
Harness the power of XPages in Lotus Dominodominion
 
IBM WebSphere Application Server Introduction for Lotus
IBM WebSphere Application Server Introduction for LotusIBM WebSphere Application Server Introduction for Lotus
IBM WebSphere Application Server Introduction for Lotusdominion
 
I know what you are going to do next summer
I know what you are going to do next summerI know what you are going to do next summer
I know what you are going to do next summerdominion
 

Destaque (9)

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

Semelhante a Error handling in XPages

UNIT III.ppt
UNIT III.pptUNIT III.ppt
UNIT III.pptAjit Mali
 
Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024kashyapneha2809
 
Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024nehakumari0xf
 
Exception Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingException Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingAboMohammad10
 
Lecture 09 Exception Handling(1 ) in c++.pptx
Lecture 09 Exception Handling(1 ) in c++.pptxLecture 09 Exception Handling(1 ) in c++.pptx
Lecture 09 Exception Handling(1 ) in c++.pptxZenLooper
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming WebStackAcademy
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongPROIDEA
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handlingKuntal Bhowmick
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profilerIhor Bobak
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
 

Semelhante a Error handling in XPages (20)

UNIT III.ppt
UNIT III.pptUNIT III.ppt
UNIT III.ppt
 
UNIT III (2).ppt
UNIT III (2).pptUNIT III (2).ppt
UNIT III (2).ppt
 
Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024Exception Handling In Java Presentation. 2024
Exception Handling In Java Presentation. 2024
 
Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024Java-Exception Handling Presentation. 2024
Java-Exception Handling Presentation. 2024
 
Exception Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception HandlingException Handling Exception Handling Exception Handling
Exception Handling Exception Handling Exception Handling
 
Unit iii
Unit iiiUnit iii
Unit iii
 
Lecture 09 Exception Handling(1 ) in c++.pptx
Lecture 09 Exception Handling(1 ) in c++.pptxLecture 09 Exception Handling(1 ) in c++.pptx
Lecture 09 Exception Handling(1 ) in c++.pptx
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
JAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - MultithreadingJAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - Multithreading
 
java exception.pptx
java exception.pptxjava exception.pptx
java exception.pptx
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
 
Class notes(week 8) on exception handling
Class notes(week 8) on exception handlingClass notes(week 8) on exception handling
Class notes(week 8) on exception handling
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydney
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
 

Mais de dominion

What is a itil and how does it relate to your collaborative environment uklug
What is a itil and how does it relate to your collaborative environment   uklugWhat is a itil and how does it relate to your collaborative environment   uklug
What is a itil and how does it relate to your collaborative environment uklugdominion
 
iOS enterprise
iOS enterpriseiOS enterprise
iOS enterprisedominion
 
cloud session uklug
cloud session uklugcloud session uklug
cloud session uklugdominion
 
Uklug 2011 administrator development synergy
Uklug 2011 administrator development synergyUklug 2011 administrator development synergy
Uklug 2011 administrator development synergydominion
 
Uklug 2011 client management
Uklug 2011 client managementUklug 2011 client management
Uklug 2011 client managementdominion
 
JavaScript blast
JavaScript blastJavaScript blast
JavaScript blastdominion
 
Populating your domino directory or any domino database with tivoli directory...
Populating your domino directory or any domino database with tivoli directory...Populating your domino directory or any domino database with tivoli directory...
Populating your domino directory or any domino database with tivoli directory...dominion
 
Uklug2011 Know your Notes
Uklug2011 Know your NotesUklug2011 Know your Notes
Uklug2011 Know your Notesdominion
 
Taking themes to the next level
Taking themes to the next levelTaking themes to the next level
Taking themes to the next leveldominion
 
Aussie outback
Aussie outbackAussie outback
Aussie outbackdominion
 
Learning to run
Learning to runLearning to run
Learning to rundominion
 
Implementing xpages extension library
Implementing xpages extension libraryImplementing xpages extension library
Implementing xpages extension librarydominion
 
Abb presentation uklug
Abb presentation uklugAbb presentation uklug
Abb presentation uklugdominion
 
Uklug2011.lotus.on.linux.report.technical.edition.v1.0
Uklug2011.lotus.on.linux.report.technical.edition.v1.0Uklug2011.lotus.on.linux.report.technical.edition.v1.0
Uklug2011.lotus.on.linux.report.technical.edition.v1.0dominion
 
Domino testing presentation
Domino testing presentationDomino testing presentation
Domino testing presentationdominion
 
Composite applications tutorial
Composite applications tutorialComposite applications tutorial
Composite applications tutorialdominion
 
Maximizing application performance
Maximizing application performanceMaximizing application performance
Maximizing application performancedominion
 
wcm domino
wcm dominowcm domino
wcm dominodominion
 
leverage dxl
leverage dxlleverage dxl
leverage dxldominion
 

Mais de dominion (20)

What is a itil and how does it relate to your collaborative environment uklug
What is a itil and how does it relate to your collaborative environment   uklugWhat is a itil and how does it relate to your collaborative environment   uklug
What is a itil and how does it relate to your collaborative environment uklug
 
iOS enterprise
iOS enterpriseiOS enterprise
iOS enterprise
 
cloud session uklug
cloud session uklugcloud session uklug
cloud session uklug
 
Uklug 2011 administrator development synergy
Uklug 2011 administrator development synergyUklug 2011 administrator development synergy
Uklug 2011 administrator development synergy
 
Uklug 2011 client management
Uklug 2011 client managementUklug 2011 client management
Uklug 2011 client management
 
JavaScript blast
JavaScript blastJavaScript blast
JavaScript blast
 
Populating your domino directory or any domino database with tivoli directory...
Populating your domino directory or any domino database with tivoli directory...Populating your domino directory or any domino database with tivoli directory...
Populating your domino directory or any domino database with tivoli directory...
 
Uklug2011 Know your Notes
Uklug2011 Know your NotesUklug2011 Know your Notes
Uklug2011 Know your Notes
 
Quickr
QuickrQuickr
Quickr
 
Taking themes to the next level
Taking themes to the next levelTaking themes to the next level
Taking themes to the next level
 
Aussie outback
Aussie outbackAussie outback
Aussie outback
 
Learning to run
Learning to runLearning to run
Learning to run
 
Implementing xpages extension library
Implementing xpages extension libraryImplementing xpages extension library
Implementing xpages extension library
 
Abb presentation uklug
Abb presentation uklugAbb presentation uklug
Abb presentation uklug
 
Uklug2011.lotus.on.linux.report.technical.edition.v1.0
Uklug2011.lotus.on.linux.report.technical.edition.v1.0Uklug2011.lotus.on.linux.report.technical.edition.v1.0
Uklug2011.lotus.on.linux.report.technical.edition.v1.0
 
Domino testing presentation
Domino testing presentationDomino testing presentation
Domino testing presentation
 
Composite applications tutorial
Composite applications tutorialComposite applications tutorial
Composite applications tutorial
 
Maximizing application performance
Maximizing application performanceMaximizing application performance
Maximizing application performance
 
wcm domino
wcm dominowcm domino
wcm domino
 
leverage dxl
leverage dxlleverage dxl
leverage dxl
 

Último

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Último (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

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
  • 4.
  • 5.
  • 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 ...)
  • 7.
  • 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
  • 11.
  • 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
  • 13.
  • 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; } }
  • 17.
  • 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
  • 22. Vince Schuurman Martin Schaefer vince.schuurman@gmail.com martin@mschaefer.nl