Open lirenhe opened 4 days ago
Java impl code would look like this (there is no range status code in clientcore, hence the full list -- except 404 which is among expected)
@HttpRequestInformation(method = HttpMethod.DELETE, path = "/items/{id}", expectedStatusCodes = { 204, 404 })
@UnexpectedResponseExceptionDetail(
statusCode = {
500,
...
599 },
exceptionBodyClass = Standard5XXResponse.class)
@UnexpectedResponseExceptionDetail(
statusCode = {
400,
401,
402,
403,
405,
406,
...
499 },
exceptionBodyClass = Standard4XXResponse.class)
@UnexpectedResponseExceptionDetail
Response<Void> deleteSync(@HostParam("endpoint") String endpoint, @PathParam("id") long id,
@HeaderParam("Accept") String accept, RequestOptions requestOptions);
PS: if there is an @error ApiError
model without status code in the op, the last line would be e.g.
@UnexpectedResponseExceptionDetail(exceptionBodyClass = ApiError.class)
Use be
try {
client.invalid();
} catch (HttpResponseException e) {
InvalidAuth error = (InvalidAuth) e.getValue();
}
epic https://github.com/microsoft/typespec/issues/5203
Need to generate the error model from the following definition:
Please also verify we could map the error by status code correctly.