当前位置: 首页>>代码示例>>Java>>正文


Java VndErrors类代码示例

本文整理汇总了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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:23,代码来源:RestControllerAdvice.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:21,代码来源:RestControllerAdvice.java

示例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());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:29,代码来源:RestControllerAdvice.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:30,代码来源:RestControllerAdvice.java

示例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());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:33,代码来源:RestControllerAdvice.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:9,代码来源:DataFlowClientException.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:12,代码来源:VndErrorResponseErrorHandler.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:13,代码来源:RestControllerAdvice.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:18,代码来源:RestControllerAdvice.java

示例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);
}
 
开发者ID:ChristophKnabe,项目名称:spring-ddd-bank,代码行数:29,代码来源:ExceptionAdvice.java

示例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;
}
 
开发者ID:dnstk,项目名称:imgate,代码行数:15,代码来源:ImgateExceptionAdvice.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:17,代码来源:RestControllerAdvice.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:24,代码来源:RestControllerAdvice.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:21,代码来源:RestControllerAdvice.java


注:本文中的org.springframework.hateoas.VndErrors类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。