• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BiokoException类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.biokoframework.utils.exception.BiokoException的典型用法代码示例。如果您正苦于以下问题:Java BiokoException类的具体用法?Java BiokoException怎么用?Java BiokoException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

BiokoException类属于org.biokoframework.utils.exception包,在下文中一共展示了BiokoException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: twoWorkingCommands

点赞 3

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
@Test
public void twoWorkingCommands() throws BiokoException {
	EntityBuilder<Login> login = new LoginBuilder().loadDefaultExample();
	login.setId("1");
	
	Fields input = new Fields();
	input.put(FieldNames.COMMAND_NAME, "POST_login");
	input.putAll(login.build(false).fields());
	
	Fields output = _system.execute(input);
	
	Fields input2 = new Fields();
	input2.put(FieldNames.COMMAND_NAME, "GET_login");
	input2.put(GenericFieldNames.USER_EMAIL, "matto");
	input2.put(GenericFieldNames.PASSWORD, "fatto");
	
	output = _system.execute(input2);
	
	assertEquals("[" + login.build(true).toJSONString() + "]", 
			JSONValue.toJSONString(output.get(GenericFieldNames.RESPONSE)));
}
 

开发者ID:bioko,
项目名称:system-a-test,
代码行数:22,
代码来源:BasicXSystemTest.java

示例2: execute

点赞 3

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
public Fields execute(Fields input) throws BiokoException {
		Fields output = new Fields();
		String commandName = input.get(FieldNames.COMMAND_NAME);
//		try {
		fLogger.info("----- Executing Command: " + commandName + " -----");
		fLogger.info("Command input: " + input.toString());
			
//		} catch (BiokoException systemException) {
//			fLogger.error("System exception", systemException);
//			throw systemException;
//		} catch (Exception exception) {
//			fLogger.error("Generic exception", exception);
//			throw new CommandException(exception);
//		}
		fLogger.info("Command output: " + output.toString());
		fLogger.info("----- Command execution finished -----");
		return output;
	}
 

开发者ID:bioko,
项目名称:system,
代码行数:19,
代码来源:XSystem.java

示例3: create

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
public static HashMap<Class<? extends BiokoException>, HttpError> create() {
	HashMap<Class<? extends BiokoException>, HttpError> exceptionMap = new HashMap<Class<? extends BiokoException>, HttpError>();
	exceptionMap.put(BadCommandInvocationException.class, new HttpError(400));
	exceptionMap.put(AuthenticationFailureException.class, new HttpError(401));
	exceptionMap.put(EntityNotFoundException.class, new HttpError(404));
	exceptionMap.put(CommandNotFoundException.class, new HttpError(404));
	
	exceptionMap.put(ValidationException.class, new HttpError(400));
	exceptionMap.put(CommandException.class, new HttpError(500));
	
	exceptionMap.put(EasterEggException.class, new HttpError(418));
	return exceptionMap;
}
 

开发者ID:bioko,
项目名称:http-test,
代码行数:14,
代码来源:HttpResponseExceptionFactory.java

示例4: build

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
@Override
public HttpServletResponse build(HttpServletResponse response, Exception exception, Fields input, Fields output) throws IOException {	
	response.setContentType(ContentType.APPLICATION_JSON.toString());
	
	LOGGER.info("Before choosing");
	response.setStatus(chooseStatusCode(exception));
	LOGGER.info("After choosing");
	
	List<ErrorEntity> errors = null;
	if (exception instanceof BiokoException) {
		errors = ((BiokoException) exception).getErrors();
	}
	
	if (errors == null ||errors.isEmpty()) {
		errors = new ArrayList<>();
		StringBuilder message = new StringBuilder()
			.append("An unexpected exception as been captured ").append(descriptionOf(exception));
			
		ErrorEntity entity = new ErrorEntity();
		entity.setAll(new Fields(
				ErrorEntity.ERROR_CODE, FieldNames.CONTAINER_EXCEPTION_CODE,
				ErrorEntity.ERROR_MESSAGE, message.toString()));
		errors.add(entity);
	}
	IOUtils.copy(new StringReader(JSONValue.toJSONString(errors)), response.getWriter());
	
	return response;
}
 

开发者ID:bioko,
项目名称:http-exposer,
代码行数:29,
代码来源:ExceptionResponseBuilderImpl.java

示例5: chooseStatusCode

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
private int chooseStatusCode(Throwable cause) {
	while (cause != null && cause != cause.getCause()) {
		if (cause instanceof BiokoException) { 
			Integer code = fStatusCodesMap.get(cause.getClass());
			if (code != null) {
				return code;
			}
		}
		cause = cause.getCause();
	}
	return HttpStatus.SC_INTERNAL_SERVER_ERROR;
}
 

开发者ID:bioko,
项目名称:http-exposer,
代码行数:13,
代码来源:ExceptionResponseBuilderImpl.java

示例6: HttpResponseBuilder

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
public HttpResponseBuilder(HashMap<Class<? extends BiokoException>, HttpError> exceptionMap) {
	fExceptionMap = exceptionMap;
}
 

开发者ID:bioko,
项目名称:http-test,
代码行数:4,
代码来源:HttpResponseBuilder.java

示例7: buildFrom

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
public HttpError buildFrom(BiokoException exception) {
	HttpError httpError = fExceptionMap.get(exception.getClass());
	httpError.setBody(exception.getErrors());
	return httpError;
}
 

开发者ID:bioko,
项目名称:http-test,
代码行数:6,
代码来源:HttpResponseBuilder.java

示例8: createMap

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
protected Map<Class<? extends BiokoException>, ? extends Integer> createMap() {
	HashMap<Class<? extends BiokoException>, Integer> map = new HashMap<>();
	
	map.put(BadCommandInvocationException.class, 400);
	map.put(AuthenticationFailureException.class, 401);
	
	map.put(EntityNotFoundException.class, 404);
	map.put(CommandNotFoundException.class, 404);
	map.put(UnknownRouteException.class, 404);

       map.put(ForbiddenAccessException.class, 403);

	map.put(ValidationException.class, 400);
	map.put(CommandException.class, 500);

	map.put(EasterEggException.class, 418);
	
	return map;
}
 

开发者ID:bioko,
项目名称:http-exposer,
代码行数:20,
代码来源:ExceptionResponseModule.java

示例9: ExceptionResponseBuilderImpl

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
@Inject
public ExceptionResponseBuilderImpl(@Named("statusCodeMap") Map<Class<? extends BiokoException>, Integer> statusCodesMap) {
	fStatusCodesMap = Collections.unmodifiableMap(statusCodesMap);
}
 

开发者ID:bioko,
项目名称:http-exposer,
代码行数:5,
代码来源:ExceptionResponseBuilderImpl.java

示例10: prepareMap

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
@Before
public void prepareMap() {
	fCodesMap = new HashMap<Class<? extends BiokoException>, Integer>();
	fCodesMap.put(MockException.class, 626);
	fCodesMap.put(CommandException.class, 747);
}
 

开发者ID:bioko,
项目名称:http-exposer,
代码行数:7,
代码来源:ExceptionResponseBuilderTest.java

示例11: TokenCreationException

点赞 2

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
public TokenCreationException(BiokoException exception) {
    super(exception);
}
 

开发者ID:bioko,
项目名称:system,
代码行数:4,
代码来源:TokenCreationException.java

示例12: configure

点赞 1

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
@Override
protected void configure() {

	bind(IExceptionResponseBuilder.class).to(ExceptionResponseBuilderImpl.class);
	
	bind(new TypeLiteral<Map<Class<? extends BiokoException>, Integer>>(){})
		.annotatedWith(Names.named("statusCodeMap"))
		.toInstance(Collections.unmodifiableMap(createMap()));
	
}
 

开发者ID:bioko,
项目名称:http-exposer,
代码行数:11,
代码来源:ExceptionResponseModule.java

示例13: missingCommandName

点赞 1

import org.biokoframework.utils.exception.BiokoException; //导入依赖的package包/类
@Test(expected = CommandException.class)
public void missingCommandName() throws BiokoException {

	_system.execute(new Fields(FieldNames.NAME, FieldNames.NAME_VALUE));
	
}
 

开发者ID:bioko,
项目名称:system-a-test,
代码行数:7,
代码来源:BasicXSystemTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)