RestServer icon indicating copy to clipboard operation
RestServer copied to clipboard

Extend RestException to also accept error object

Open MPrtenjak opened this issue 4 years ago • 0 comments

This enables the developer to return additional data to user. So in case of an error in REST function, the error can be additionaly explained

in code:

throw new RestException(400, "Missing properties", ["severity" => "high", "missing" => ['date', 'name']]);

in REST response

{
    "error": {
        "code": 400,
        "message": "Missing properties",
        "data": {
            "severity": "high",
            "missing": [
                "date",
                "name"
            ]
        }
    }
}

MPrtenjak avatar Dec 12 '21 15:12 MPrtenjak