Permalink
Browse files

Shouldn't die even if some URLs got errors.

  • Loading branch information...
1 parent 5c25b71 commit ec9a51b365bfe8c5067ecd94ec260a581c9d568f @hiratara committed Mar 15, 2012
Showing with 22 additions and 19 deletions.
  1. +19 −19 get_teacup.pl
  2. +3 −0 moto.tt
View
@@ -38,35 +38,34 @@ sub child{
my $text = $l->text;
my $url = $l->url_abs();
- my $c = undef;
- {
+ my (@members, @logs);
+ eval {
my $m = get_mech;
$m->get($url);
-#warn $m->status;
- $c = $m->content;
-#warn $c;
- }
-
- my $parsed = $scraper->scrape( \$c );
-
- ( my $members = $parsed->{members} || '' ) =~ s/^\xa0//; # remove  
- my @members = split(/, /, $members);
-
- my @logs;
- for( @{ $parsed->{logs} } ){
- if (m/^(.*) > (.*)\([^)]+\)$/) {
- push @logs, {NAME => split_tag($1), COMMENT => split_tag($2)};
- } else {
- warn $_;
+ my $c = $m->content;
+
+ my $parsed = $scraper->scrape( \$c );
+
+ ( my $members = $parsed->{members} || '' ) =~ s/^\xa0//; # remove  
+ @members = split(/, /, $members);
+
+ for ( @{ $parsed->{logs} } ) {
+ if (m/^(.*) > (.*)\([^)]+\)$/) {
+ push @logs, {NAME => split_tag($1), COMMENT => split_tag($2)};
+ } else {
+ warn $_;
+ }
}
- }
+ };
+ warn my $error = $@ if $@;
return {
url => $url,
text => $text,
members => \@members,
logs => \@logs,
+ error => $error,
};
}
@@ -111,6 +110,7 @@ sub child{
DISP => $ret->{text},
MEMBERS => $ret->{members},
LOGS => $ret->{logs},
+ ERROR => $ret->{error},
};
}
View
@@ -75,6 +75,9 @@ function load_tooltip(){
<a href="[% R.URL %]" title="[% FOR L=R.LOGS.reverse %][% L.NAME | html %]「[% L.COMMENT | html %]」&#x0d;&#x0a;[% END %]" class="room_link">[% R.DISP %]</a>
</div>
<div class="members">
+ [% IF R.ERROR %]
+ <div style="color:red;">読み込み中にエラーがおきました</div>
+ [% END %]
[% FOREACH M=R.MEMBERS %]
<span class="member-name">[% M %]</span>
[%- IF ! loop.last %]・[% END %]

0 comments on commit ec9a51b

Please sign in to comment.