root/websites/mobilecat/trunk/lib/MobileCat/Base.pm

Revision 16852, 1.2 kB (checked in by tomi-ru, 19 months ago)

登録系

Line 
1package MobileCat::Base;
2use strict;
3use warnings;
4use base 'Catalyst::Controller::Mobile::JP';
5
6sub default :Path {
7    my ($self, $c) = @_;
8    $c->error(404);
9}
10
11sub end :Private {
12    my ($self, $c) = @_;
13   
14    $c->stash->{encoding} = $self->encoding;
15    $c->forward('render');
16    $c->forward('error');
17    $c->forward( $c->view('MobileJpFilter') );
18
19    $self->next::method($c);
20}
21
22sub render :ActionClass('RenderView') {
23    my ($self, $c) = @_;
24}
25
26sub error :Private {
27    my ($self, $c) = @_;
28   
29    if ($c->stash->{error}) {
30        $c->log->error('error: '. $c->stash->{error});
31    }
32    if ($c->form->has_error) {
33        $c->log->error('validate error:'. join(', ', $c->form->error));
34    }
35   
36    return unless @{ $c->error };
37   
38    my $errcode;
39    if (grep { $c->error->[0] eq $_ } qw/401 404 503/) {
40        $errcode = shift @{ $c->error };
41    }
42    if (my @errors = @{ $c->error } and not $c->debug) {
43        $c->log->error($_) for @errors;
44        $c->clear_errors;
45        $errcode = 503;
46    }
47    if ($errcode) {
48        $c->res->status($errcode);
49       
50        return unless $c->res->content_type =~ /html$/;
51        $c->view('TT')->template("error/$errcode.tt");
52        $c->forward( $c->view('TT') );
53    }
54}
55
561;
Note: See TracBrowser for help on using the browser.