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 61476dc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/MusicBrainz/Server/Test/WS.pm
Expand Up @@ -21,10 +21,12 @@ our @EXPORT_OK = qw(

Readonly our $FORBIDDEN_JSON_RESPONSE => {
error => 'You are not authorized to access this resource.',
help => 'For usage, please see: https://musicbrainz.org/development/mmd',
};

Readonly our $UNAUTHORIZED_JSON_RESPONSE => {
error => 'Your credentials could not be verified. Either you supplied the wrong credentials (e.g., bad password), or your client doesn\'t understand how to supply the credentials required.',
help => 'For usage, please see: https://musicbrainz.org/development/mmd',
};

Readonly our $FORBIDDEN_XML_RESPONSE => <<'EOXML';
Expand Down
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 61476dc

Please sign in to comment.