Last modified by Ray Kiddy on 2021/04/22 20:40

Hide last authors
Pascal Robert 4.1 1 == Exception Page ==
smmccraw 1.1 2
arroz 5.1 3 To provide a custom error handler when an exception is thrown, override this WOApplication method:
smmccraw 1.1 4
Quinton Dolan 3.1 5 {{code}}
smmccraw 1.1 6
Quinton Dolan 3.1 7 public WOResponse handleException (java.lang.Exception anException, WOContext aContext) { }
smmccraw 1.1 8
Quinton Dolan 3.1 9 {{/code}}
smmccraw 1.1 10
11 For example:
12
Quinton Dolan 3.1 13 {{code}}
smmccraw 1.1 14
Quinton Dolan 3.1 15 public WOResponse handleException(Exception _exception, WOContext _context) {
16 Session session = (Session) _context.session();
17 // do something to notify user of exception, maybe put a message in the session here ...
18 WOResponse response;
19 if (/* you can't handle exception*/) {
20 response = super.handleException(_exception, _context);
21 }
22 else {
23 response = pageWithName(YourExceptionPage.class.getName(), _context).generateResponse();
24 }
25 return response;
Pascal Robert 4.1 26 }
smmccraw 1.1 27
Quinton Dolan 3.1 28 {{/code}}
smmccraw 1.1 29
Pascal Robert 4.1 30 == Session Expired ==
smmccraw 1.1 31
32 To provide a custom error handler when an exception is thrown, override the method:
33
Quinton Dolan 3.1 34 {{code}}
smmccraw 1.1 35
Quinton Dolan 3.1 36 public WOResponse handleSessionRestorationErrorInContext(WOContext _context) {
smmccraw 1.1 37
Quinton Dolan 3.1 38 {{/code}}
smmccraw 1.1 39
40 For example:
41
Quinton Dolan 3.1 42 {{code}}
smmccraw 1.1 43
Quinton Dolan 3.1 44 public WOResponse handleSessionRestorationErrorInContext(WOContext _context) {
45 Session session = (Session) _context.session();
46 // do something to notify user of exception, maybe put a message in the session here ...
47 WOResponse response = pageWithName(YourErrorPage.class.getName(), _context).generateResponse();
48 return response;
49 }
smmccraw 1.1 50
Quinton Dolan 3.1 51 {{/code}}
smmccraw 1.1 52
Pascal Robert 4.1 53 == Your Request Produced an Error ==
smmccraw 1.1 54
Pascal Robert 4.1 55 === Chuck Hill ===
smmccraw 1.1 56
57 This message started to appear in WO 5.2 when an exception was raised in a DirectAction, but only in deployed applications. Here is what is happening:
58
59 WODisplayExceptionPages
Ray Kiddy 9.1 60 true or false to enable or disable the generation of WOExceptionPages for direct action requests. Default is true in development mode and false in deployment mode.
smmccraw 1.1 61
Ray Kiddy 9.1 62 FromĀ [[https:~~/~~/developer.apple.com/library/archive/documentation/WebObjects/WOAppProperties/Articles/ApplicationProperties.html#~~/~~/apple_ref/doc/uid/TP40005337-SW1>>url:https://developer.apple.com/library/archive/documentation/WebObjects/WOAppProperties/Articles/ApplicationProperties.html#//apple_ref/doc/uid/TP40005337-SW1||shape="rect"]]
smmccraw 1.1 63
64 If the page being returned throws during appendToResponse and the app is deployed, all that is displayed is a blank page with the words "Your request produced an error".
65
66 To avoid this, either add this to the launch agruments:
67
Quinton Dolan 3.1 68 {{noformat}}
smmccraw 1.1 69
Quinton Dolan 3.1 70 -DWODisplayExceptionPages=true
smmccraw 1.1 71
Quinton Dolan 3.1 72 {{/noformat}}
smmccraw 1.1 73
74 Or change the main method in your Application class to look like this:
75
Quinton Dolan 3.1 76 {{code}}
smmccraw 1.1 77
Quinton Dolan 3.1 78 public static void main(String argv[]) {
79 System.setProperty("WODisplayExceptionPages", "true");
80 WOApplication.main(argv, Application.class);
81 }
smmccraw 1.1 82
Quinton Dolan 3.1 83 {{/code}}
smmccraw 1.1 84
85 This won't work if you put it in the constructor.