Skip to content

Commit

Permalink
Output doc link with JSON WS error message
Browse files Browse the repository at this point in the history
JSON WS now outputs the same doc link as the XML WS error message.
  • Loading branch information
yvanzo committed Jun 4, 2019
1 parent 6654559 commit 0a058e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/MusicBrainz/Server/WebService/JSONSerializer.pm
Expand Up @@ -129,7 +129,10 @@ sub autocomplete_editor {
sub output_error {
my ($self, $err) = @_;

return encode_json({ error => $err });
return encode_json({
error => $err,
help => 'For usage, please see: https://musicbrainz.org/development/mmd',
});
}

sub output_success {
Expand Down
Expand Up @@ -21,7 +21,10 @@ test 'errors' => sub {
$mech->get('/ws/2/release?recording=7b1f6e95-b523-43b6-a048-810ea5d463a8');
is($mech->status, 404, 'browse releases via non-existent recording');

is_json($mech->content, encode_json({ error => "Not Found" }));
is_json($mech->content, encode_json({
error => "Not Found",
help => 'For usage, please see: https://musicbrainz.org/development/mmd',
}));
};

test 'browse releases via artist (paging)' => sub {
Expand Down
Expand Up @@ -22,12 +22,16 @@ test 'errors' => sub {
is($mech->status, 400);

is_json($mech->content, encode_json({
error => "coffee is not a valid inc parameter for the artist resource."
error => "coffee is not a valid inc parameter for the artist resource.",
help => 'For usage, please see: https://musicbrainz.org/development/mmd',
}));

$mech->get('/ws/2/artist/00000000-1111-2222-3333-444444444444');
is($mech->status, 404);
is_json($mech->content, encode_json({ error => "Not Found" }));
is_json($mech->content, encode_json({
error => "Not Found",
help => 'For usage, please see: https://musicbrainz.org/development/mmd',
}));
};

test 'basic artist lookup' => sub {
Expand Down

0 comments on commit 0a058e4

Please sign in to comment.