org.apache.kylin.rest.response.ErrorResponse Java Examples

The following examples show how to use org.apache.kylin.rest.response.ErrorResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
ErrorResponse handleError(HttpServletRequest req, Exception ex) {
    logger.error("", ex);

    Message msg = MsgPicker.getMsg();
    Throwable cause = ex;
    while (cause != null) {
        if (cause.getClass().getPackage().getName().startsWith("org.apache.hadoop.hbase")) {
            return new ErrorResponse(req.getRequestURL().toString(), new InternalErrorException(
                    String.format(Locale.ROOT, msg.getHBASE_FAIL(), ex.getMessage()), ex));
        }
        cause = cause.getCause();
    }

    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #2
Source File: BaseControllerTest.java    From Kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasics() throws IOException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("http://localhost");

    NotFoundException notFoundException = new NotFoundException("not found");
    ErrorResponse errorResponse = basicController.handleBadRequest(request, notFoundException);
    Assert.assertNotNull(errorResponse);

    ForbiddenException forbiddenException = new ForbiddenException("forbidden");
    errorResponse = basicController.handleForbidden(request, forbiddenException);
    Assert.assertNotNull(errorResponse);

    InternalErrorException internalErrorException = new InternalErrorException("error");
    errorResponse = basicController.handleError(request, internalErrorException);
    Assert.assertNotNull(errorResponse);

    BadRequestException badRequestException = new BadRequestException("error");
    errorResponse = basicController.handleBadRequest(request, badRequestException);
    Assert.assertNotNull(errorResponse);
}
 
Example #3
Source File: BasicController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
ErrorResponse handleError(HttpServletRequest req, Exception ex) {
    logger.error("", ex);

    Message msg = MsgPicker.getMsg();
    Throwable cause = ex;
    while (cause != null) {
        if (cause.getClass().getPackage().getName().startsWith("org.apache.hadoop.hbase")) {
            return new ErrorResponse(req.getRequestURL().toString(), new InternalErrorException(
                    String.format(Locale.ROOT, msg.getHBASE_FAIL(), ex.getMessage()), ex));
        }
        cause = cause.getCause();
    }

    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #4
Source File: BaseControllerTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasics() throws IOException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("http://localhost");

    NotFoundException notFoundException = new NotFoundException("not found");
    ErrorResponse errorResponse = basicController.handleBadRequest(request, notFoundException);
    Assert.assertNotNull(errorResponse);

    ForbiddenException forbiddenException = new ForbiddenException("forbidden");
    errorResponse = basicController.handleForbidden(request, forbiddenException);
    Assert.assertNotNull(errorResponse);

    InternalErrorException internalErrorException = new InternalErrorException("error");
    errorResponse = basicController.handleError(request, internalErrorException);
    Assert.assertNotNull(errorResponse);

    BadRequestException badRequestException = new BadRequestException("error");
    errorResponse = basicController.handleBadRequest(request, badRequestException);
    Assert.assertNotNull(errorResponse);
}
 
Example #5
Source File: BaseControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasics() throws IOException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("http://localhost");

    NotFoundException notFoundException = new NotFoundException("not found");
    ErrorResponse errorResponse = basicController.handleBadRequest(request, notFoundException);
    Assert.assertNotNull(errorResponse);

    ForbiddenException forbiddenException = new ForbiddenException("forbidden");
    errorResponse = basicController.handleForbidden(request, forbiddenException);
    Assert.assertNotNull(errorResponse);

    InternalErrorException internalErrorException = new InternalErrorException("error");
    errorResponse = basicController.handleError(request, internalErrorException);
    Assert.assertNotNull(errorResponse);

    BadRequestException badRequestException = new BadRequestException("error");
    errorResponse = basicController.handleBadRequest(request, badRequestException);
    Assert.assertNotNull(errorResponse);
}
 
Example #6
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(BadRequestException.class)
@ResponseBody
ErrorResponse handleBadRequest(HttpServletRequest req, Exception ex) {
    logger.error("", ex);
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #7
Source File: BasicController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(BadRequestException.class)
@ResponseBody
ErrorResponse handleBadRequest(HttpServletRequest req, Exception ex) {
    logger.error("", ex);
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #8
Source File: BasicController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
ErrorResponse handleError(HttpServletRequest req, Exception ex) {
    logger.error("", ex);
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #9
Source File: BasicController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(BadRequestException.class)
@ResponseBody
ErrorResponse handleBadRequest(HttpServletRequest req, Exception ex) {
    logger.error("", ex);
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #10
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(UnauthorizedException.class)
@ResponseBody
ErrorResponse handleUnauthorized(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #11
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.TOO_MANY_REQUESTS)
@ExceptionHandler(TooManyRequestException.class)
@ResponseBody
ErrorResponse handleTooManyRequest(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #12
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
@ResponseBody
ErrorResponse handleNotFound(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #13
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(ForbiddenException.class)
@ResponseBody
ErrorResponse handleForbidden(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #14
Source File: BasicController.java    From kylin with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(ForbiddenException.class)
@ResponseBody
ErrorResponse handleForbidden(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #15
Source File: BasicController.java    From kylin with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
@ResponseBody
ErrorResponse handleNotFound(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #16
Source File: BasicController.java    From kylin with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(UnauthorizedException.class)
@ResponseBody
ErrorResponse handleUnauthorized(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #17
Source File: BasicController.java    From kylin with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.TOO_MANY_REQUESTS)
@ExceptionHandler(TooManyRequestException.class)
@ResponseBody
ErrorResponse handleTooManyRequest(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #18
Source File: BasicController.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(ForbiddenException.class)
@ResponseBody
ErrorResponse handleForbidden(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #19
Source File: BasicController.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
@ResponseBody
ErrorResponse handleNotFound(HttpServletRequest req, Exception ex) {
    return new ErrorResponse(req.getRequestURL().toString(), ex);
}