-rw-r--r-- | components/exception_dev | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/components/exception_dev b/components/exception_dev index d62f462..49b7f45 100644 --- a/components/exception_dev +++ b/components/exception_dev | |||
@@ -1,91 +1,91 @@ | |||
1 | %%decl using namespace std; | 1 | %%decl using namespace std; |
2 | <%impl> | 2 | <%impl> |
3 | #include <iostream> | 3 | #include <iostream> |
4 | #include <fstream> | 4 | #include <fstream> |
5 | #include <sstream> | 5 | #include <sstream> |
6 | #include <cassert> | 6 | #include <cassert> |
7 | #include <cstdarg> | 7 | #include <cstdarg> |
8 | #include <stdexcept> | 8 | #include <stdexcept> |
9 | #include <cxxabi.h> | 9 | #include <cxxabi.h> |
10 | #include <sitecing/sitecing_util.h> | 10 | #include <sitecing/sitecing_util.h> |
11 | #include <sitecing/util.h> | 11 | #include <sitecing/util.h> |
12 | #include <sitecing/magic.h> | 12 | #include <sitecing/magic.h> |
13 | #include <konforka/util.h> | 13 | #include <konforka/util.h> |
14 | #include <konforka/exception.h> | 14 | #include <konforka/exception.h> |
15 | </%impl> | 15 | </%impl> |
16 | %%var string message; | 16 | %%var string message; |
17 | %%var string root_source; | 17 | %%var string root_source; |
18 | %%var string root_intermediate; | 18 | %%var string root_intermediate; |
19 | %%var string root_so; | 19 | %%var string root_so; |
20 | %%var string component; | 20 | %%var string component; |
21 | %%var int line_number = -1; | 21 | %%var int line_number = -1; |
22 | %%var const exception* exception_caught; | 22 | %%var const exception* exception_caught; |
23 | <%code> | 23 | <%code> |
24 | __SCIF->headers.clear(); | 24 | __SCIF->headers.clear(); |
25 | __SCIF->out->seekp(0); | 25 | __SCIF->out->seekp(0); |
26 | int magic = _magic; | 26 | int magic = _magic; |
27 | va_list va = _args; | 27 | va_list va; va_copy(va,_args); |
28 | switch(magic) { | 28 | switch(magic) { |
29 | case sitecing::__magic_compile_error: | 29 | case sitecing::__magic_compile_error: |
30 | message = va_arg(va,const char*); | 30 | message = va_arg(va,const char*); |
31 | root_source = va_arg(va,const char*); | 31 | root_source = va_arg(va,const char*); |
32 | root_intermediate = va_arg(va,const char*); | 32 | root_intermediate = va_arg(va,const char*); |
33 | root_so = va_arg(va,const char*); | 33 | root_so = va_arg(va,const char*); |
34 | component = va_arg(va,const char*); | 34 | component = va_arg(va,const char*); |
35 | break; | 35 | break; |
36 | case sitecing::__magic_preprocess_error: | 36 | case sitecing::__magic_preprocess_error: |
37 | message = va_arg(va,const char*); | 37 | message = va_arg(va,const char*); |
38 | root_source = va_arg(va,const char*); | 38 | root_source = va_arg(va,const char*); |
39 | root_intermediate = va_arg(va,const char*); | 39 | root_intermediate = va_arg(va,const char*); |
40 | root_so = va_arg(va,const char*); | 40 | root_so = va_arg(va,const char*); |
41 | component = va_arg(va,const char*); | 41 | component = va_arg(va,const char*); |
42 | line_number = va_arg(va,int); | 42 | line_number = va_arg(va,int); |
43 | break; | 43 | break; |
44 | case sitecing::__magic_generic_exception: | 44 | case sitecing::__magic_generic_exception: |
45 | message = va_arg(va,const char*); | 45 | message = va_arg(va,const char*); |
46 | root_source = va_arg(va,const char*); | 46 | root_source = va_arg(va,const char*); |
47 | root_intermediate = va_arg(va,const char *); | 47 | root_intermediate = va_arg(va,const char *); |
48 | root_so = va_arg(va,const char *); | 48 | root_so = va_arg(va,const char *); |
49 | component = va_arg(va,const char*); | 49 | component = va_arg(va,const char*); |
50 | exception_caught = va_arg(va,const exception*); | 50 | exception_caught = va_arg(va,const exception*); |
51 | break; | 51 | break; |
52 | default: | 52 | default: |
53 | break; | 53 | break; |
54 | } | 54 | } |
55 | </%code> | 55 | </%code> |
56 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | 56 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
57 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | 57 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
58 | <head> | 58 | <head> |
59 | <title><% message %></title> | 59 | <title><% message %></title> |
60 | <style type="text/css"> | 60 | <style type="text/css"> |
61 | <!-- | 61 | <!-- |
62 | body { | 62 | body { |
63 | font-family: sans-serif; | 63 | font-family: sans-serif; |
64 | font-size: 11pt; | 64 | font-size: 11pt; |
65 | } | 65 | } |
66 | 66 | ||
67 | h1 { | 67 | h1 { |
68 | font-family: serif; | 68 | font-family: serif; |
69 | font-size: 130%; | 69 | font-size: 130%; |
70 | font-weight: bold; | 70 | font-weight: bold; |
71 | text-align: center; | 71 | text-align: center; |
72 | } | 72 | } |
73 | p { | 73 | p { |
74 | text-indent: 2em; | 74 | text-indent: 2em; |
75 | text-align: justify; | 75 | text-align: justify; |
76 | } | 76 | } |
77 | 77 | ||
78 | dl.exception-props { | 78 | dl.exception-props { |
79 | margin: 1ex 1em; | 79 | margin: 1ex 1em; |
80 | padding: 0.5ex; | 80 | padding: 0.5ex; |
81 | border: solid 1px gray; | 81 | border: solid 1px gray; |
82 | background-color: #e0e0e0; | 82 | background-color: #e0e0e0; |
83 | } | 83 | } |
84 | dl.exception-props dt { | 84 | dl.exception-props dt { |
85 | font-weight: bold; | 85 | font-weight: bold; |
86 | color: blue; | 86 | color: blue; |
87 | } | 87 | } |
88 | dl.exception-props dd { | 88 | dl.exception-props dd { |
89 | color: gray; | 89 | color: gray; |
90 | } | 90 | } |
91 | 91 | ||
@@ -265,83 +265,84 @@ | |||
265 | cumulative += line; | 265 | cumulative += line; |
266 | } | 266 | } |
267 | if(!(cumulative.empty() || error_file.empty() || error_line<0)) { | 267 | if(!(cumulative.empty() || error_file.empty() || error_line<0)) { |
268 | error_file = "/"+konforka::combine_path(root_source+component,error_file); | 268 | error_file = "/"+konforka::combine_path(root_source+component,error_file); |
269 | report_error(error_file,error_line,remove_roots(cumulative)); | 269 | report_error(error_file,error_line,remove_roots(cumulative)); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | </%code> | 272 | </%code> |
273 | </div> | 273 | </div> |
274 | </%method> | 274 | </%method> |
275 | <%method void handle_unknown_error() %> | 275 | <%method void handle_unknown_error() %> |
276 | <div class="exception-unknown"> | 276 | <div class="exception-unknown"> |
277 | <h1>unknown error</h1> | 277 | <h1>unknown error</h1> |
278 | </div> | 278 | </div> |
279 | </%method> | 279 | </%method> |
280 | <%method void report_error(const string& file,long line,const string& message) %> | 280 | <%method void report_error(const string& file,long line,const string& message) %> |
281 | <div class="exception-codepoint-report"> | 281 | <div class="exception-codepoint-report"> |
282 | <h3><% sitecing::html_escape(strip_roots(file)) %></h3> | 282 | <h3><% sitecing::html_escape(strip_roots(file)) %></h3> |
283 | <%code> | 283 | <%code> |
284 | if(line>=0) { | 284 | if(line>=0) { |
285 | int firstline = line-5, lastline = line+5; | 285 | int firstline = line-5, lastline = line+5; |
286 | if(firstline<1) | 286 | if(firstline<1) |
287 | firstline = 1; | 287 | firstline = 1; |
288 | ifstream ifs(file.c_str(),ios::in); | 288 | ifstream ifs(file.c_str(),ios::in); |
289 | if(ifs.bad()) { | 289 | if(ifs.bad()) { |
290 | // TODO: | 290 | // TODO: |
291 | }else{ | 291 | }else{ |
292 | for(int l=1;l<firstline && !ifs.eof();l++) { | 292 | for(int l=1;l<firstline && !ifs.eof();l++) { |
293 | ifs.ignore(65536,'\n'); | 293 | ifs.ignore(65536,'\n'); |
294 | } | 294 | } |
295 | if(ifs.eof()) { | 295 | if(ifs.eof()) { |
296 | // TODO: no such line in file | 296 | // TODO: no such line in file |
297 | }else{ | 297 | }else{ |
298 | <%output><ul></%output> | 298 | <%output><ul></%output> |
299 | for(int l=firstline;l<=lastline && !ifs.eof();l++) { | 299 | for(int l=firstline;l<=lastline && !ifs.eof();l++) { |
300 | string str; | 300 | string str; |
301 | getline(ifs,str); | 301 | getline(ifs,str); |
302 | for(string::size_type t=str.find('\t');t!=string::npos;t=str.find('\t')) { | 302 | for(string::size_type t=str.find('\t');t!=string::npos;t=str.find('\t')) { |
303 | str.replace(t,1,8-(t%8),' '); | 303 | str.replace(t,1,8-(t%8),' '); |
304 | } | 304 | } |
305 | char tln[16]; | 305 | char tln[16]; |
306 | snprintf(tln,sizeof(tln),"%5d",l); | 306 | snprintf(tln,sizeof(tln),"%5d",l); |
307 | <%output> | 307 | <%output> |
308 | <li class="<% l==line?"focused":"unfocused" %>"><span class="lineno"><% sitecing::html_escape(tln,sitecing::html_escape_nbsp) %></span> <span class="line"><% sitecing::html_escape(str,sitecing::html_escape_nbsp) %></span></li> | 308 | <li class="<% l==line?"focused":"unfocused" %>"><span class="lineno"><% sitecing::html_escape(tln,sitecing::html_escape_nbsp) %></span> <span class="line"><% sitecing::html_escape(str,sitecing::html_escape_nbsp) %></span></li> |
309 | </%output> | 309 | </%output> |
310 | } | 310 | } |
311 | <%output></ul></%output> | 311 | <%output></ul></%output> |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | </%code> | 315 | </%code> |
316 | <div class="what"> | 316 | <div class="what"> |
317 | <% sitecing::html_escape(message,sitecing::html_escape_br) %> | 317 | <% sitecing::html_escape(message,sitecing::html_escape_br) %> |
318 | </div> | 318 | </div> |
319 | </div> | 319 | </div> |
320 | </%method> | 320 | </%method> |
321 | <%codemethod string strip_roots(const string& filename) %> | 321 | <%codemethod string strip_roots(const string& filename) %> |
322 | string np = konforka::normalize_path(filename); | 322 | string np = konforka::normalize_path(filename); |
323 | try{ | 323 | try{ |
324 | return sitecing::strip_prefix(np,root_source); | 324 | return sitecing::strip_prefix(np,root_source); |
325 | }catch(sitecing::utility_no_prefix& e){ } | 325 | }catch(sitecing::utility_no_prefix& e){ } |
326 | try{ | 326 | try{ |
327 | return sitecing::strip_prefix(np,root_intermediate); | 327 | return sitecing::strip_prefix(np,root_intermediate); |
328 | }catch(sitecing::utility_no_prefix& e){ } | 328 | }catch(sitecing::utility_no_prefix& e){ } |
329 | return np; | ||
329 | </%codemethod> | 330 | </%codemethod> |
330 | <%codemethod string remove_roots(const string& str) %> | 331 | <%codemethod string remove_roots(const string& str) %> |
331 | string rv = str; | 332 | string rv = str; |
332 | string::size_type rp; | 333 | string::size_type rp; |
333 | string::size_type rl = root_source.length(); | 334 | string::size_type rl = root_source.length(); |
334 | while((rp=rv.find(root_source))!=string::npos) { | 335 | while((rp=rv.find(root_source))!=string::npos) { |
335 | rv.erase(rp,rl); | 336 | rv.erase(rp,rl); |
336 | } | 337 | } |
337 | rl = root_intermediate.length(); | 338 | rl = root_intermediate.length(); |
338 | while((rp=rv.find(root_intermediate))!=string::npos) { | 339 | while((rp=rv.find(root_intermediate))!=string::npos) { |
339 | rv.erase(rp,rl); | 340 | rv.erase(rp,rl); |
340 | } | 341 | } |
341 | rl = root_so.length(); | 342 | rl = root_so.length(); |
342 | while((rp=rv.find(root_so))!=string::npos) { | 343 | while((rp=rv.find(root_so))!=string::npos) { |
343 | rv.erase(rp,rl); | 344 | rv.erase(rp,rl); |
344 | } | 345 | } |
345 | return rv; | 346 | return rv; |
346 | </%codemethod> | 347 | </%codemethod> |
347 | % /* vim:set ft=sitecing: */ | 348 | % /* vim:set ft=sitecing: */ |