mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-07-02 07:18:53 +00:00
fix #6503: return api handler errors in the json body
similar to what we do for the extjs formatter, put the error message or status message in the 'message' property of the return object. This way client libraries can extract the error without having to parse the HTTP status reason phrase (which is not possible in all http libraries, e.g. hyperium's http rust crate). This should not be a breaking change, since it just adds a (semi) new field to the return value. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
d3dd84ee70
commit
9a2112e664
@ -33,6 +33,10 @@ sub prepare_response_data {
|
||||
$res->{status} = 200;
|
||||
}
|
||||
$new->{success} = $success;
|
||||
} elsif ($format eq 'json') {
|
||||
if (HTTP::Status::is_error($res->{status})) {
|
||||
$new->{message} = "$res->{message}" || status_message($res->{status});
|
||||
}
|
||||
}
|
||||
|
||||
if ($success && $res->{total}) {
|
||||
|
Loading…
Reference in New Issue
Block a user