本文整理汇总了Java中org.springframework.hateoas.VndErrors类的典型用法代码示例。如果您正苦于以下问题:Java VndErrors类的具体用法?Java VndErrors怎么用?Java VndErrors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VndErrors类属于org.springframework.hateoas包,在下文中一共展示了VndErrors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInvalidTaskName
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
@Test
@DirtiesContext
public void testInvalidTaskName() throws Exception {
String exceptionMessage = null;
final String ERROR_MESSAGE =
"Could not find task definition named " + TASK_NAME;
VndErrors errors = new VndErrors("message", ERROR_MESSAGE, new Link("ref"));
Mockito.doThrow(new DataFlowClientException(errors))
.when(this.taskOperations)
.launch(Matchers.anyString(),
(Map<String, String>) Matchers.any(),
(List<String>) Matchers.any());
TaskLauncherTasklet taskLauncherTasklet = getTaskExecutionTasklet();
ChunkContext chunkContext = chunkContext();
try {
taskLauncherTasklet.execute(null, chunkContext);
}
catch (DataFlowClientException dfce) {
exceptionMessage = dfce.getMessage();
}
assertEquals(ERROR_MESSAGE+"\n", exceptionMessage);
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:23,代码来源:TaskLauncherTaskletTests.java
示例2: onNotFoundException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Log the exception message at warn level and stack trace as trace level.
* Return response status HttpStatus.NOT_FOUND
*/
@ExceptionHandler({NoSuchAppRegistrationException.class,
NoSuchTaskDefinitionException.class,
NoSuchTaskExecutionException.class,
NoSuchJobExecutionException.class,
NoSuchJobInstanceException.class,
NoSuchJobException.class,
NoSuchStepExecutionException.class,
MetricsMvcEndpoint.NoSuchMetricException.class})
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public VndErrors onNotFoundException(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例3: onClientGenericBadRequest
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Client did not formulate a correct request.
* Log the exception message at warn level and stack trace as trace level.
* Return response status HttpStatus.BAD_REQUEST (400).
*/
@ExceptionHandler({
MissingServletRequestParameterException.class,
MethodArgumentTypeMismatchException.class,
InvalidStreamDefinitionException.class
})
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public VndErrors onClientGenericBadRequest(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例4: onConstraintViolationException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* The exception handler is trigger if a JSR303 {@link ConstraintViolationException}
* is being raised.
*
* Log the exception message at warn level and stack trace as trace level.
* Return response status HttpStatus.BAD_REQUEST (400).
*/
@ExceptionHandler({ConstraintViolationException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public VndErrors onConstraintViolationException(ConstraintViolationException e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
final StringBuilder errorMessage = new StringBuilder();
boolean first = true;
for (ConstraintViolation<?> violation : e.getConstraintViolations()) {
if (!first) {
errorMessage.append("; ");
}
errorMessage.append(violation.getMessage());
first = false;
}
return new VndErrors(logref, errorMessage.toString());
}
示例5: onNotFoundException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Log the exception message at warn level and stack trace as trace level. Return
* response status HttpStatus.NOT_FOUND
*
* @param e one of the exceptions, {@link NoSuchStreamDefinitionException},
* {@link NoSuchAppRegistrationException}, {@link NoSuchTaskDefinitionException},
* {@link NoSuchTaskExecutionException}, {@link NoSuchJobExecutionException},
* {@link NoSuchJobInstanceException}, {@link NoSuchJobException},
* {@link NoSuchStepExecutionException},
* {@link MetricsMvcEndpoint.NoSuchMetricException}, {@link NoSuchAppException}, or
* {@link NoSuchAppInstanceException}
* @return the error response in JSON format with media type
* application/vnd.error+json
*/
@ExceptionHandler({ NoSuchStreamDefinitionException.class, NoSuchAppRegistrationException.class,
NoSuchTaskDefinitionException.class, NoSuchTaskExecutionException.class, NoSuchJobExecutionException.class,
NoSuchJobInstanceException.class, NoSuchJobException.class, NoSuchStepExecutionException.class,
MetricsMvcEndpoint.NoSuchMetricException.class, NoSuchAppException.class,
NoSuchAppInstanceException.class, ApplicationDoesNotExistException.class })
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public VndErrors onNotFoundException(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例6: onConstraintViolationException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* The exception handler is trigger if a JSR303 {@link ConstraintViolationException}
* is being raised.
* <p>
* Log the exception message at warn level and stack trace as trace level. Return
* response status HttpStatus.BAD_REQUEST (400).
*
* @param e the exceptions, {@link ConstraintViolationException}
* @return the error response in JSON format with media type
* application/vnd.error+json
*/
@ExceptionHandler({ ConstraintViolationException.class })
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public VndErrors onConstraintViolationException(ConstraintViolationException e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
final StringBuilder errorMessage = new StringBuilder();
boolean first = true;
for (ConstraintViolation<?> violation : e.getConstraintViolations()) {
if (!first) {
errorMessage.append("; ");
}
errorMessage.append(violation.getMessage());
first = false;
}
return new VndErrors(logref, errorMessage.toString());
}
示例7: getMessage
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
@Override
public String getMessage() {
StringBuilder builder = new StringBuilder();
for (VndErrors.VndError e : vndErrors) {
builder.append(e.getMessage()).append('\n');
}
return builder.toString();
}
示例8: handleError
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
@Override
public void handleError(ClientHttpResponse response) throws IOException {
VndErrors error = null;
try {
error = errorExtractor.extractData(response);
}
catch (Exception e) {
super.handleError(response);
}
throw new DataFlowClientException(error);
}
示例9: onException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Handles the general error case. Log track trace at error level
*/
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public VndErrors onException(Exception e) {
logger.error("Caught exception while handling a request", e);
String logref = e.getClass().getSimpleName();
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例10: onConflictException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Log the exception message at warn level and stack trace as trace level.
* Return response status HttpStatus.CONFLICT
*/
@ExceptionHandler({
AppAlreadyRegisteredException.class,
DuplicateTaskException.class})
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody
public VndErrors onConflictException(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例11: reportException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
@ResponseBody
@ExceptionHandler({Exception.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
/**Reports the given Exception with messages localized according to the given Locale of the web request.*/
VndErrors reportException(final Exception ex, final Locale requestLocale) {
//prepare messages for client with the Locale of the request:
/** Message texts for exceptions. */
final ResourceBundle requestResourceBundle = ResourceBundle.getBundle(BASE_NAME, requestLocale);
final StringBuffer clientMessages = new StringBuffer();
multex.Msg.printMessages(clientMessages, ex, requestResourceBundle);
final String clientMesagesString = clientMessages.toString();
//prepare log report with messages and stack trace:
final StringBuffer serverMessages = new StringBuffer();
serverMessages.append("Processing REST request threw exception:\n");
final Locale defaultLocale = Locale.getDefault();
final ResourceBundle defaultResourceBundle = ResourceBundle.getBundle(BASE_NAME, defaultLocale);
if(!defaultResourceBundle.equals(requestResourceBundle)) {
serverMessages.append(clientMesagesString);
serverMessages.append("\n-----\n");
}
Msg.printReport(serverMessages, ex, defaultResourceBundle);
//log the report on the server:
log.error(serverMessages.toString());
//respond with localized messages to the client:
return new VndErrors("error", clientMesagesString);
}
示例12: methodArgumentTypeMismatchExceptionHandler
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
@ResponseBody
@ExceptionHandler
@ResponseStatus(HttpStatus.FORBIDDEN)
VndErrors methodArgumentTypeMismatchExceptionHandler(MethodArgumentTypeMismatchException ex) {
Throwable th = ex;
while (th != null) {
if (th instanceof InvalidAccessException) {
return invalidAccessExceptionHandler((InvalidAccessException) th);
} else {
th = th.getCause();
}
}
throw ex;
}
示例13: onException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Handles the general error case. Log track trace at error level
*
* @param e the exception not handled by other exception handler methods
* @return the error response in JSON format with media type
* application/vnd.error+json
*/
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public VndErrors onException(Exception e) {
logger.error("Caught exception while handling a request", e);
String logref = e.getClass().getSimpleName();
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例14: onConflictException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Log the exception message at warn level and stack trace as trace level. Return
* response status HttpStatus.CONFLICT
*
* @param e one of the exceptions, {@link AppAlreadyRegisteredException},
* {@link DuplicateStreamDefinitionException}, {@link DuplicateTaskException},
* {@link StreamAlreadyDeployedException}, {@link StreamAlreadyDeployingException}, or
* {@link StreamAlreadyDeployingException}
* @return the error response in JSON format with media type
* application/vnd.error+json
*/
@ExceptionHandler({ AppAlreadyRegisteredException.class, DuplicateStreamDefinitionException.class,
DuplicateTaskException.class, StreamAlreadyDeployedException.class, StreamAlreadyDeployingException.class })
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody
public VndErrors onConflictException(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}
示例15: onUnprocessableEntityException
import org.springframework.hateoas.VndErrors; //导入依赖的package包/类
/**
* Log the exception message at warn level and stack trace as trace level. Return
* response status HttpStatus.UNPROCESSABLE_ENTITY
*
* @param e one of the exceptions, {@link JobNotRestartableException} or
* {@link JobExecutionNotRunningException}
* @return the error response in JSON format with media type
* application/vnd.error+json
*/
@ExceptionHandler({ JobNotRestartableException.class, JobExecutionNotRunningException.class })
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY)
@ResponseBody
public VndErrors onUnprocessableEntityException(Exception e) {
String logref = logWarnLevelExceptionMessage(e);
if (logger.isTraceEnabled()) {
logTraceLevelStrackTrace(e);
}
String msg = getExceptionMessage(e);
return new VndErrors(logref, msg);
}