Search in sources :

Example 1 with ThingsboardErrorCode

use of org.thingsboard.server.common.data.exception.ThingsboardErrorCode in project thingsboard by thingsboard.

the class ThingsboardErrorResponseHandler method handleThingsboardException.

private void handleThingsboardException(ThingsboardException thingsboardException, HttpServletResponse response) throws IOException {
    ThingsboardErrorCode errorCode = thingsboardException.getErrorCode();
    HttpStatus status = errorCodeToStatus(errorCode);
    response.setStatus(status.value());
    mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(thingsboardException.getMessage(), errorCode, status));
}
Also used : HttpStatus(org.springframework.http.HttpStatus) ThingsboardErrorCode(org.thingsboard.server.common.data.exception.ThingsboardErrorCode)

Aggregations

HttpStatus (org.springframework.http.HttpStatus)1 ThingsboardErrorCode (org.thingsboard.server.common.data.exception.ThingsboardErrorCode)1