Search in sources :

Example 1 with BadRequestException

use of org.wso2.carbon.apimgt.rest.api.common.exception.BadRequestException in project carbon-apimgt by wso2.

the class RestApiUtil method handleBadRequest.

/**
 * Logs the error, builds a BadRequestException with specified details and throws it
 *
 * @param msg error message
 * @param log Log instance
 * @throws BadRequestException If 400 bad request comes.
 */
public static void handleBadRequest(String msg, Logger log) throws BadRequestException {
    BadRequestException badRequestException = buildBadRequestException(msg);
    log.error(msg);
    throw badRequestException;
}
Also used : BadRequestException(org.wso2.carbon.apimgt.rest.api.common.exception.BadRequestException)

Example 2 with BadRequestException

use of org.wso2.carbon.apimgt.rest.api.common.exception.BadRequestException in project carbon-apimgt by wso2.

the class BadRequestExceptionTestCase method testGetMessage.

@Test
public void testGetMessage() throws Exception {
    ErrorDTO errorDTO = new ErrorDTO();
    errorDTO.setDescription(testMessage);
    BadRequestException badRequestException = new BadRequestException(errorDTO);
    String message = badRequestException.getMessage();
    Assert.assertEquals(message, testMessage);
}
Also used : ErrorDTO(org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO) BadRequestException(org.wso2.carbon.apimgt.rest.api.common.exception.BadRequestException) Test(org.testng.annotations.Test)

Aggregations

BadRequestException (org.wso2.carbon.apimgt.rest.api.common.exception.BadRequestException)2 Test (org.testng.annotations.Test)1 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)1