| 1 |
wakaba |
1.1 |
#?SuikaWikiConfig/2.0 |
| 2 |
|
|
|
| 3 |
|
|
Plugin: |
| 4 |
|
|
@Name: Error |
| 5 |
|
|
@Description: |
| 6 |
|
|
@@@: Error handling core module |
| 7 |
|
|
@@lang:en |
| 8 |
|
|
@License: %%GPL%% |
| 9 |
|
|
@Author: |
| 10 |
|
|
@@Name: |
| 11 |
|
|
@@@@: Wakaba |
| 12 |
|
|
@@@lang:ja |
| 13 |
|
|
@@@script:Latn |
| 14 |
|
|
@@Mail[list]: [email protected] |
| 15 |
wakaba |
1.2 |
@Date.RCS: $Date: 2003/12/01 07:39:25 $ |
| 16 |
wakaba |
1.1 |
@RequiredModule[list]: |
| 17 |
|
|
@RequiredPlugin[list]: |
| 18 |
|
|
WikiView |
| 19 |
|
|
WikiStruct |
| 20 |
|
|
HTML |
| 21 |
|
|
WikiResource |
| 22 |
|
|
@Use: |
| 23 |
|
|
|
| 24 |
|
|
PluginConst: |
| 25 |
|
|
@NS_XHTML1: |
| 26 |
|
|
http://www.w3.org/1999/xhtml |
| 27 |
|
|
|
| 28 |
|
|
ViewDefinition: |
| 29 |
|
|
@Mode: -error |
| 30 |
|
|
@Condition: |
| 31 |
|
|
@@http-method[list]: |
| 32 |
|
|
GET |
| 33 |
|
|
HEAD |
| 34 |
|
|
@Description: |
| 35 |
|
|
@@@: Error reporting special "view" |
| 36 |
|
|
@@lang: en |
| 37 |
|
|
@template: |
| 38 |
|
|
@@http-status-code: 500 |
| 39 |
|
|
@@http-status-phrase: Internal WikiEngine Error |
| 40 |
|
|
@@media-type: text/html |
| 41 |
|
|
@@use-media-type-charset: 1 |
| 42 |
|
|
@@expires: %%error%% |
| 43 |
|
|
@@body: |
| 44 |
|
|
%html-document ( |
| 45 |
|
|
title => {%res (name => {Error:WebPageTitle});}p, |
| 46 |
|
|
link-meta => {%template (name => links);}p, |
| 47 |
|
|
content => { |
| 48 |
|
|
%section (level=>2, |
| 49 |
|
|
title => {%res (name => {Error:Title});}p, heading, |
| 50 |
|
|
content => {%paragraph ( |
| 51 |
|
|
content => {%res (name => {Error:Description});}p, |
| 52 |
|
|
);%error-list ( |
| 53 |
|
|
no-error => {%res (name => {Error:NoErrorReported});}p, |
| 54 |
|
|
);}p, |
| 55 |
|
|
); |
| 56 |
|
|
}p, |
| 57 |
|
|
); |
| 58 |
|
|
|
| 59 |
|
|
ViewFragment: |
| 60 |
|
|
@Name: ws--post-content |
| 61 |
|
|
@Description: |
| 62 |
|
|
@@@: After content body -- error report |
| 63 |
|
|
@@lang:en |
| 64 |
|
|
@Order: 850 |
| 65 |
|
|
@Formatting: |
| 66 |
|
|
%section (level=>2, |
| 67 |
|
|
title => {%res (name => {Error:Title});}p, heading, |
| 68 |
|
|
content => {%error-list;}p, |
| 69 |
|
|
); |
| 70 |
|
|
|
| 71 |
|
|
ViewDefinition: |
| 72 |
|
|
@Mode: -error-error |
| 73 |
|
|
@Condition: |
| 74 |
|
|
@@http-method[list]: |
| 75 |
|
|
GET |
| 76 |
|
|
HEAD |
| 77 |
|
|
@Description: |
| 78 |
|
|
@@@: |
| 79 |
|
|
Error reporting special "view" used when "-error" also problematic |
| 80 |
|
|
@@lang: en |
| 81 |
|
|
@method: |
| 82 |
|
|
@@Name:main |
| 83 |
|
|
@@@: |
| 84 |
|
|
require SuikaWiki::Output::HTTP; |
| 85 |
|
|
$opt2->{output} = SuikaWiki::Output::HTTP->new |
| 86 |
|
|
(wiki => $self->{view}->{wiki}, |
| 87 |
|
|
view => $self->{view}, viewobj => $self); |
| 88 |
|
|
$opt2->{output}->{status_code} = 500; |
| 89 |
|
|
$opt2->{output}->{status_phrase} = q#Internal WikiEngine Error#; |
| 90 |
|
|
$opt2->{output}->{entity}->{media_type} = q#text/html#; |
| 91 |
|
|
$opt2->{output}->{entity}->{charset} = 'iso-8859-1'; |
| 92 |
|
|
$opt2->{output}->set_expires (%{$self->{view}->{wiki}->{config}->{entity}->{expires}->{q#error#}}); |
| 93 |
|
|
|
| 94 |
|
|
my $html = new Message::Markup::XML::Node |
| 95 |
|
|
(type => '#element', |
| 96 |
|
|
namespace_uri => $NS_XHTML1, |
| 97 |
|
|
local_name => 'html'); |
| 98 |
|
|
$html->append_new_node (type => '#element', |
| 99 |
|
|
namespace_uri => $NS_XHTML1, |
| 100 |
|
|
local_name => 'head') |
| 101 |
|
|
->append_new_node (type => '#element', |
| 102 |
|
|
namespace_uri => $NS_XHTML1, |
| 103 |
|
|
local_name => 'title') |
| 104 |
|
|
->append_text ('500 Internal WikiEngine Error'); |
| 105 |
|
|
|
| 106 |
|
|
my $body = $html->append_new_node (type => '#element', |
| 107 |
|
|
namespace_uri => $NS_XHTML1, |
| 108 |
|
|
local_name => 'body'); |
| 109 |
|
|
$body->append_new_node (type => '#element', |
| 110 |
|
|
namespace_uri => $NS_XHTML1, |
| 111 |
|
|
local_name => 'h1') |
| 112 |
|
|
->append_text ('Internal WikiEngine Error'); |
| 113 |
|
|
|
| 114 |
|
|
$body->append_new_node (type => '#element', |
| 115 |
|
|
namespace_uri => $NS_XHTML1, |
| 116 |
|
|
local_name => 'p') |
| 117 |
|
|
->append_text (q(The WikiEngine encounted an internal error or misconfiguration and was unable to complete your request.)); |
| 118 |
|
|
$body->append_new_node (type => '#element', |
| 119 |
|
|
namespace_uri => $NS_XHTML1, |
| 120 |
|
|
local_name => 'p') |
| 121 |
|
|
->append_text (q(Additionally, another error was encounted while trying to report that error.)); |
| 122 |
|
|
|
| 123 |
|
|
my $ol = $body->append_new_node (namespace_uri => $NS_XHTML1, |
| 124 |
|
|
local_name => 'ol', |
| 125 |
|
|
type => '#element'); |
| 126 |
|
|
for (@{$self->{view}->{wiki}->{var}->{error}||[]}) { |
| 127 |
|
|
my $li = $ol->append_new_node (type => '#element', |
| 128 |
|
|
namespace_uri => $NS_XHTML1, |
| 129 |
|
|
local_name => 'li'); |
| 130 |
|
|
$li->append_node ($_->{description}, node_or_text => 1); |
| 131 |
|
|
} |
| 132 |
|
|
|
| 133 |
|
|
$opt2->{output}->{entity}->{body} = $html->stringify; |
| 134 |
|
|
$opt2->{output}->output (output => 'http-cgi'); |
| 135 |
|
|
|
| 136 |
|
|
FormattingRule: |
| 137 |
|
|
@Category[list]: |
| 138 |
|
|
view |
| 139 |
|
|
view-resource |
| 140 |
|
|
@Name: error-list |
| 141 |
|
|
@Description: |
| 142 |
|
|
@@@: Listing reported errors |
| 143 |
|
|
@@lang:en |
| 144 |
|
|
@Parameter: |
| 145 |
|
|
@@Name: no-error |
| 146 |
|
|
@@Type: node |
| 147 |
|
|
@@Default: "" |
| 148 |
|
|
@@Description: |
| 149 |
|
|
@@@@: List item text to be inserted if no error reported |
| 150 |
|
|
@@@lang:en |
| 151 |
|
|
@Formatting: |
| 152 |
|
|
my $ol = ref ($p->{-parent})->new (namespace_uri => $NS_XHTML1, |
| 153 |
|
|
local_name => 'ol', |
| 154 |
|
|
type => '#element'); |
| 155 |
|
|
for (@{$o->{wiki}->{var}->{error}||[]}) { |
| 156 |
|
|
my $li = $ol->append_new_node (type => '#element', |
| 157 |
|
|
namespace_uri => $NS_XHTML1, |
| 158 |
|
|
local_name => 'li'); |
| 159 |
|
|
$li->append_node ($_->{description}, node_or_text => 1); |
| 160 |
|
|
} |
| 161 |
wakaba |
1.2 |
$o->{wiki}->{var}->{error} = []; |
| 162 |
wakaba |
1.1 |
if ($ol->count == 0) { |
| 163 |
|
|
my $no_error = __ATTRNODE:%no_error__; |
| 164 |
|
|
$ol->append_new_node |
| 165 |
|
|
(type => '#element', |
| 166 |
|
|
namespace_uri => $NS_XHTML1, |
| 167 |
|
|
local_name => 'li') |
| 168 |
|
|
->append_node ($no_error) if $no_error->count; |
| 169 |
|
|
} |
| 170 |
|
|
$p->{-parent}->append_node ($ol) if $ol->count; |
| 171 |
|
|
|
| 172 |
|
|
Function: |
| 173 |
|
|
@Name: make_caller_trace_table |
| 174 |
|
|
@Description: |
| 175 |
|
|
@@@: Generating an HTML table of caller stack trace |
| 176 |
|
|
@@lang:en |
| 177 |
|
|
@Main: |
| 178 |
|
|
my (undef, $parent, $opt) = @_; |
| 179 |
|
|
my $tbl = $parent->append_new_node (type => '#element', |
| 180 |
|
|
namespace_uri => $NS_XHTML1, |
| 181 |
|
|
local_name => 'table') |
| 182 |
|
|
->append_new_node (type => '#element', |
| 183 |
|
|
namespace_uri => $NS_XHTML1, |
| 184 |
|
|
local_name => 'tbody'); |
| 185 |
|
|
for (my $i = $opt->{skip}; defined caller ($i); $i++) { |
| 186 |
|
|
my $tr = $tbl->append_new_node (type => '#element', |
| 187 |
|
|
namespace_uri => $NS_XHTML1, |
| 188 |
|
|
local_name => 'tr'); |
| 189 |
|
|
for (caller ($i)) { |
| 190 |
|
|
$tr->append_new_node (type => '#element', |
| 191 |
|
|
namespace_uri => $NS_XHTML1, |
| 192 |
|
|
local_name => 'td') |
| 193 |
|
|
->append_text ($_); |
| 194 |
|
|
} |
| 195 |
|
|
} |
| 196 |
|
|
|
| 197 |
|
|
Function: |
| 198 |
|
|
@Name: report_error_simple |
| 199 |
|
|
@Description: |
| 200 |
|
|
@@@: |
| 201 |
|
|
Simple reporter of error encounted while processing formatting rules |
| 202 |
|
|
@@lang:en |
| 203 |
|
|
@Main: |
| 204 |
|
|
my (undef, $wiki) = (shift, shift); |
| 205 |
|
|
my $error = {}; |
| 206 |
|
|
my $dl = $error->{description} |
| 207 |
|
|
= new Message::Markup::XML::Node |
| 208 |
|
|
(type => '#element', |
| 209 |
|
|
namespace_uri => $NS_XHTML1, |
| 210 |
|
|
local_name => 'dl'); |
| 211 |
|
|
my %opt; |
| 212 |
|
|
while (@_) { |
| 213 |
|
|
my ($name, $val) = (shift, shift); |
| 214 |
|
|
if (substr ($name, 0, 1) eq '-') { |
| 215 |
|
|
$opt{$name} = $val; |
| 216 |
|
|
next; |
| 217 |
|
|
} |
| 218 |
|
|
## TODO: Use resource |
| 219 |
|
|
$dl->append_new_node (type => '#element', |
| 220 |
|
|
namespace_uri => $NS_XHTML1, |
| 221 |
|
|
local_name => 'dt') |
| 222 |
|
|
->append_text ($name); |
| 223 |
|
|
$dl->append_new_node (type => '#element', |
| 224 |
|
|
namespace_uri => $NS_XHTML1, |
| 225 |
|
|
local_name => 'dd') |
| 226 |
|
|
->append_text ($val); |
| 227 |
|
|
} |
| 228 |
|
|
if ($opt{-trace}) { |
| 229 |
|
|
$dl->append_new_node (type => '#element', |
| 230 |
|
|
namespace_uri => $NS_XHTML1, |
| 231 |
|
|
local_name => 'dt') |
| 232 |
|
|
->append_text ('Call stack trace'); |
| 233 |
|
|
__FUNCPACK__->make_caller_trace_table |
| 234 |
|
|
($dl->append_new_node (type => '#element', |
| 235 |
|
|
namespace_uri => $NS_XHTML1, |
| 236 |
|
|
local_name => 'dd'), |
| 237 |
|
|
{skip => 2}); |
| 238 |
|
|
} |
| 239 |
|
|
push @{$wiki->{var}->{error}||=[]}, $error; |
| 240 |
|
|
|
| 241 |
|
|
Function: |
| 242 |
|
|
@Name: reporting_formatting_template_error |
| 243 |
|
|
@Description: |
| 244 |
|
|
@@@: |
| 245 |
|
|
Reporting formatting-template-text error in "-error" special view |
| 246 |
|
|
mode and throwing "ERROR_REPORTED" error. |
| 247 |
|
|
@Main: |
| 248 |
|
|
my (undef, $err, $wiki) = @_; |
| 249 |
|
|
my $error = {}; |
| 250 |
|
|
my $dl = $error->{description} |
| 251 |
|
|
= new Message::Markup::XML::Node |
| 252 |
|
|
(type => '#element', |
| 253 |
|
|
namespace_uri => $NS_XHTML1, |
| 254 |
|
|
local_name => 'dl'); |
| 255 |
|
|
## TODO: Use resource |
| 256 |
|
|
$dl->append_new_node (type => '#element', |
| 257 |
|
|
namespace_uri => $NS_XHTML1, |
| 258 |
|
|
local_name => 'dt') |
| 259 |
|
|
->append_text ('Error condition'); |
| 260 |
|
|
$dl->append_new_node (type => '#element', |
| 261 |
|
|
namespace_uri => $NS_XHTML1, |
| 262 |
|
|
local_name => 'dd') |
| 263 |
|
|
->append_text ($err->text); |
| 264 |
|
|
$dl->append_new_node (type => '#element', |
| 265 |
|
|
namespace_uri => $NS_XHTML1, |
| 266 |
|
|
local_name => 'dt') |
| 267 |
|
|
->append_text ('Formatting context'); |
| 268 |
|
|
$dl->append_new_node (type => '#element', |
| 269 |
|
|
namespace_uri => $NS_XHTML1, |
| 270 |
|
|
local_name => 'dd') |
| 271 |
|
|
->append_text (qq($err->{-formatter}->{-category_name})); |
| 272 |
|
|
$dl->append_new_node (type => '#element', |
| 273 |
|
|
namespace_uri => $NS_XHTML1, |
| 274 |
|
|
local_name => 'dt') |
| 275 |
|
|
->append_text ('Call stack trace'); |
| 276 |
|
|
__FUNCPACK__->make_caller_trace_table |
| 277 |
|
|
($dl->append_new_node (type => '#element', |
| 278 |
|
|
namespace_uri => $NS_XHTML1, |
| 279 |
|
|
local_name => 'dd'), |
| 280 |
|
|
{skip => 2}); |
| 281 |
|
|
push @{$wiki->{var}->{error}||=[]}, $error; |
| 282 |
|
|
|
| 283 |
|
|
Resource: |
| 284 |
|
|
@Error:Description: |
| 285 |
|
|
@@@: |
| 286 |
|
|
The WikiEngine encounted an internal error or misconfiguration and |
| 287 |
|
|
was unable to complete your request. |
| 288 |
|
|
@@lang:en |
| 289 |
|
|
@Error:NoErrorReported: |
| 290 |
|
|
@@@: No error reported |
| 291 |
|
|
@@lang:en |
| 292 |
|
|
@Error:Title: |
| 293 |
|
|
@@@: Internal WikiEngine Error |
| 294 |
|
|
@@lang:en |
| 295 |
|
|
@Error:WebPageTitle: |
| 296 |
|
|
@@@: %page-name; (Error) |
| 297 |
|
|
@@lang:en |
| 298 |
|
|
|