Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

avoid crash if YAML file is invalid

  • Loading branch information...
commit b65be830031a1a8822936708efbeee8bcf131a2f 1 parent 74579c3
Gabor Szabo authored

Showing 1 changed file with 12 additions and 1 deletion. Show diff stats Hide diff stats

  1. +12 1 lib/PEG.pm
13 lib/PEG.pm
@@ -3,6 +3,7 @@ use Dancer ':syntax';
3 3
4 4 use Encode qw(decode);
5 5 use XML::RSS;
  6 +use Data::Dumper qw(Dumper);
6 7 use DateTime;
7 8 use Data::ICal;
8 9 use Data::ICal::Entry::Event;
@@ -30,7 +31,10 @@ sub _read_file {
30 31
31 32 my $sub = $name eq 'news' ? 'news' : 'events';
32 33 if (not $content{data}{$name} or $content{stamp}{$name} < $current_stamp) {
33   - my $data = YAML::LoadFile($file);
  34 + my $data = eval { YAML::LoadFile($file) };
  35 + if ($@) {
  36 + warn "could not load '$file' $@";
  37 + }
34 38 if ($name eq 'news') {
35 39 $content{data}{$name}{$sub} = $data;
36 40 } elsif ($name eq 'events') {
@@ -204,6 +208,10 @@ sub _event_text {
204 208
205 209 $text .= "<br />";
206 210 if ($n->{url}) {
  211 + if (not defined $n->{title}) {
  212 + warn "title is missing " . Dumper $n;
  213 + $n->{title} = 'NA';
  214 + }
207 215 $text .= qq{ <a href="$n->{url}">$n->{title}</a><br /> };
208 216 }
209 217 if ($n->{wiki}) {
@@ -211,6 +219,9 @@ sub _event_text {
211 219 my $wiki = "http://perlfoundation.org/perl5/$n->{wiki}";
212 220 $text .= qq{ Presence is being organized on the <a href="$wiki">wiki</a><br /> };
213 221 }
  222 + if (not defined $n->{address}) {
  223 + warn "address is missing " . Dumper $n;
  224 + }
214 225 $text .= " Location: $n->{address}<br />";
215 226 return $text;
216 227 }

0 comments on commit b65be83

Please sign in to comment.
Something went wrong with that request. Please try again.