Skip to content

bytemechanics/type-ex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Type-ex

Latest version Quality Gate Coverage License

Type-ex it's a library to make easy application errors classification.

Motivation

In the old times all application errors were indexed in never-ending lists in big manuals to describe the possible problems and its solutions.

Quick start

  1. First of all include the Jar file in your compile and execution classpath. Maven
	<dependency>
		<groupId>org.bytemechanics</groupId>
		<artifactId>type-ex</artifactId>
		<version>X.X.X</version>
	</dependency>

Graddle

dependencies {
    compile 'org.bytemechanics:type-ex:X.X.X'
}
  1. Create your typified exceptions
package mypackage;
import org.bytemechanics.typeex.impl.TypifiedException;
public enum MyExceptionType implements ExceptionType<TypifiedException>{
	EXCEPTION_TYPE_NO_PARAMETERIZED("This message has no substitution parameters"),
	EXCEPTION_TYPE_PARAMETERIZED("This message has two {} substitution parameters {}"),
	;	
	private final String message;
	MyExceptionType(final String _message){
		this.message=_message;
	}	
	@Override
	public String getMessage() {
		return this.message;
	}
}
  1. Launch an exception Manually
throw MyExceptionType.EXCEPTION_TYPE_PARAMETERIZED
						.from(cause)
						.with("String1",1);

From lambda

Optional.of(null)
		.orElseThrow(MyExceptionType.EXCEPTION_TYPE_PARAMETERIZED
						.from(cause)
						.with("String1",1))

About

Library to create exceptions typified in a enumerated, in order to be able to list all possible exceptions in one application.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •