Validate: Human-readable error messages
This commit is contained in:
parent
e4b6b77e1b
commit
e5755ddd80
3 changed files with 79 additions and 56 deletions
4
FU.pm
4
FU.pm
|
|
@ -640,8 +640,8 @@ sub _getfield($data, @a) {
|
|||
require FU::Validate;
|
||||
my $schema = FU::Validate->compile(@a > 1 ? { keys => {@a} } : $a[0]);
|
||||
my $res = eval { $schema->validate($data) };
|
||||
fu->error(400, "Input validation failed") if $@; # TODO: More detailed error message
|
||||
return @a == 2 ? $res->data->{$a[0]} : $res->data;
|
||||
fu->error(400, "Input validation failed: $@") if $@;
|
||||
return @a == 2 ? $res->{$a[0]} : $res;
|
||||
}
|
||||
|
||||
sub query {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue