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

From version 2.1
edited by smmccraw
on 2007/07/08 09:45
Change comment: There is no comment for this version
To version 3.1
edited by Quinton Dolan
on 2007/07/12 20:51
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.smmccraw
1 +XWiki.qdolan
Content
... ... @@ -2,54 +2,53 @@
2 2  
3 3  To provide a custom error handler when an exception is thrown, override the method:
4 4  
5 -{{panel}}
5 +{{code}}
6 6  
7 - public WOResponse handleException (java.lang.Exception anException, WOContext aContext) { }
7 +public WOResponse handleException (java.lang.Exception anException, WOContext aContext) { }
8 8  
9 -{{/panel}}
9 +{{/code}}
10 10  
11 11  For example:
12 12  
13 -{{panel}}
13 +{{code}}
14 14  
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;
26 - }
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;
26 +}
27 27  
28 -{{/panel}}
28 +{{/code}}
29 29  
30 30  == Session Expired ==
31 31  
32 32  To provide a custom error handler when an exception is thrown, override the method:
33 33  
34 -{{panel}}
34 +{{code}}
35 35  
36 - public WOResponse handleSessionRestorationErrorInContext(WOContext _context) {
36 +public WOResponse handleSessionRestorationErrorInContext(WOContext _context) {
37 37  
38 -{{/panel}}
38 +{{/code}}
39 39  
40 40  For example:
41 41  
42 -{{panel}}
42 +{{code}}
43 43  
44 -
45 - public WOResponse handleSessionRestorationErrorInContext(WOContext _context) {
46 - Session session = (Session) _context.session();
47 - // do something to notify user of exception, maybe put a message in the session here ...
48 - WOResponse response = pageWithName(YourErrorPage.class.getName(), _context).generateResponse();
49 - return response;
50 - }
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 +}
51 51  
52 -{{/panel}}
51 +{{/code}}
53 53  
54 54  == Your Request Produced an Error ==
55 55  
... ... @@ -60,28 +60,28 @@
60 60  WODisplayExceptionPages
61 61  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.
62 62  
63 -From http:~/~/developer.apple.com/documentation/WebObjects/WOAppProperties/AppProperties/chapter_1_section_1.html
62 +From [[http://developer.apple.com/documentation/WebObjects/WOAppProperties/AppProperties/chapter_1_section_1.html]]
64 64  
65 65  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".
66 66  
67 67  To avoid this, either add this to the launch agruments:
68 68  
69 -{{panel}}
68 +{{noformat}}
70 70  
71 - -DWODisplayExceptionPages=true
70 +-DWODisplayExceptionPages=true
72 72  
73 -{{/panel}}
72 +{{/noformat}}
74 74  
75 75  Or change the main method in your Application class to look like this:
76 76  
77 -{{panel}}
76 +{{code}}
78 78  
79 - public static void main(String argv[]) {
80 - System.setProperty("WODisplayExceptionPages", "true");
81 - WOApplication.main(argv, Application.class);
82 - }
78 +public static void main(String argv[]) {
79 + System.setProperty("WODisplayExceptionPages", "true");
80 + WOApplication.main(argv, Application.class);
81 +}
83 83  
84 -{{/panel}}
83 +{{/code}}
85 85  
86 86  This won't work if you put it in the constructor.
87 87