Permalink
Browse files

some quick fixes

  • Loading branch information...
rizen committed Nov 28, 2017
1 parent 9c6487f commit 09acd238059b18843d8a826f869ca4832d215750
Showing with 13 additions and 8 deletions.
  1. +13 −8 lib/Wing/Role/Result/JSONField.pm
@@ -43,16 +43,21 @@ sub wing_json_field {
$class->meta->add_around_method_modifier($field => sub {
if (scalar @_ == 3 && defined $_[2]) {
my ($orig, $self, $json) = @_;
my $perl = eval { from_json($json) };
if ($@) {
my $error = $@;
$error =~ m/^(.*)\sat\s.*/;
my $help = $1;
Wing->log->warn($field.': '. $error);
ouch 442, 'Invalid JSON for '.$field.': '.$help, $field;
if (ref $json eq 'ARRAY' || ref $json eq 'HASH') {
return $orig->($self, $json);
}
else {
return $self->$orig($perl);
my $perl = eval { from_json($json) };
if ($@) {
my $error = $@;
$error =~ m/^(.*)\sat\s.*/;
my $help = $1;
Wing->log->warn($field.': '. $error);
ouch 442, 'Invalid JSON for '.$field.': '.$help, $field;
}
else {
return $orig->($self, $perl);
}
}
}
return $_[0]->($_[1]);

0 comments on commit 09acd23

Please sign in to comment.