Mercurial > pub > Impl
comparison Lib/IMPL/Web/Handler/ErrorHandler.pm @ 353:feeb3bc4a818
corrected error handling while loading templates
corrected variables lookup in controls
updated handles to use the new view features
| author | cin |
|---|---|
| date | Fri, 11 Oct 2013 15:49:04 +0400 |
| parents | 32aceba4ee6d |
| children | 69a1f1508696 |
comparison
equal
deleted
inserted
replaced
| 352:675cd1829255 | 353:feeb3bc4a818 |
|---|---|
| 15 'IMPL::Object::Autofill' => '@_', | 15 'IMPL::Object::Autofill' => '@_', |
| 16 'IMPL::Object::Serializable' => undef | 16 'IMPL::Object::Serializable' => undef |
| 17 }, | 17 }, |
| 18 props => [ | 18 props => [ |
| 19 errors => PROP_RW, | 19 errors => PROP_RW, |
| 20 loader => PROP_RW, | 20 view => PROP_RW, |
| 21 layout => PROP_RW, | |
| 21 fallback => PROP_RW, | 22 fallback => PROP_RW, |
| 22 contentType => PROP_RW | 23 contentType => PROP_RW |
| 23 ] | 24 ] |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 sub CTOR { | 27 sub CTOR { |
| 27 my ($this) = @_; | 28 my ($this) = @_; |
| 28 | 29 |
| 29 die ArgumentException->new("loader") unless $this->loader; | 30 die ArgumentException->new("view") unless $this->view; |
| 30 die ArgumentException->new("fallback") unless $this->fallback; | 31 die ArgumentException->new("fallback") unless $this->fallback; |
| 31 | 32 |
| 32 $this->errors({}) unless $this->errors; | 33 $this->errors({}) unless $this->errors; |
| 33 | 34 |
| 34 } | 35 } |
| 42 $result = $next ? $next->($action) : undef; | 43 $result = $next ? $next->($action) : undef; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 if (my $err = $@) { | 46 if (my $err = $@) { |
| 46 | 47 |
| 47 warn "$err"; | 48 warn "error handler: $err"; |
| 48 | 49 |
| 49 my $vars = { | 50 my $vars = { |
| 50 error => $err | 51 error => $err |
| 51 }; | 52 }; |
| 52 | 53 |
| 56 $status = $err->status; | 57 $status = $err->status; |
| 57 } | 58 } |
| 58 | 59 |
| 59 my ($code) = ($status =~ m/^(\d+)/); | 60 my ($code) = ($status =~ m/^(\d+)/); |
| 60 | 61 |
| 61 my $doc = $this->loader->document( | 62 my $text = $this->view->display( |
| 62 $this->errors->{$code} || $this->fallback, | 63 $err, |
| 63 $vars | 64 $this->errors->{$code} || $this->fallback, |
| 64 ); | 65 { |
| 65 | 66 layout => $this->layout |
| 66 my $text = $doc->Render($vars); | 67 } |
| 68 ); | |
| 67 | 69 |
| 68 $result = HttpResponse->new( | 70 $result = HttpResponse->new( |
| 69 status => $status, | 71 status => $status, |
| 70 type => $this->contentType, | 72 type => $this->contentType, |
| 71 charset => 'utf-8', | 73 charset => 'utf-8', |
