Skip to content
Browse files

Parse and simplify incoming xml in one try/catch step

  • Loading branch information...
1 parent ce1243d commit a9d0cd43b0b708d2899ec5fa8d9990470211394d @sanko committed Jun 21, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/AnyEvent/MSN.pm
View
12 lib/AnyEvent/MSN.pm
@@ -1002,13 +1002,15 @@ XML
# Random private methods
sub _parse_xml {
- my $s = shift;
+ my ($s, $data) = @_;
state $xml_twig //= XML::Twig->new();
- $xml_twig->parse(shift); # build it
- my $xml;
- try { $xml = $xml_twig->simplify(keyattr => [qw[type id value]]) }
+ my $xml = {};
+ try {
+ $xml_twig->parse($data);
+ $xml = $xml_twig->simplify(keyattr => [qw[type id value]]);
+ }
catch { $s->trigger_error(qq[parsing XML: $_], 1) };
- $xml // {};
+ $xml;
}
# Non-OOP utility functions

0 comments on commit a9d0cd4

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