https://github.com/bytemechanics/type-ex
Library to create exceptions typified in a enumerated, in order to be able to list all possible exceptions in one application.
https://github.com/bytemechanics/type-ex
exception-repository exceptions exceptions-typified java library
Last synced: about 1 year ago
JSON representation
Library to create exceptions typified in a enumerated, in order to be able to list all possible exceptions in one application.
- Host: GitHub
- URL: https://github.com/bytemechanics/type-ex
- Owner: bytemechanics
- License: apache-2.0
- Created: 2017-11-25T16:05:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-09T15:52:03.000Z (about 7 years ago)
- Last Synced: 2025-02-12T06:24:24.423Z (over 1 year ago)
- Topics: exception-repository, exceptions, exceptions-typified, java, library
- Language: Java
- Homepage: https://type-ex.bytemechanics.org
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Type-ex
[](https://maven-badges.herokuapp.com/maven-central/org.bytemechanics/type-ex/badge.svg)
[](https://sonarcloud.io/dashboard/index/org.bytemechanics%3Atype-ex)
[](https://sonarcloud.io/dashboard/index/org.bytemechanics%3Atype-ex)
[](https://opensource.org/licenses/Apache-2.0)
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**
```Maven
org.bytemechanics
type-ex
X.X.X
```
**Graddle**
```Gradle
dependencies {
compile 'org.bytemechanics:type-ex:X.X.X'
}
```
1. Create your typified exceptions
```Java
package mypackage;
import org.bytemechanics.typeex.impl.TypifiedException;
public enum MyExceptionType implements ExceptionType{
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**
```Java
throw MyExceptionType.EXCEPTION_TYPE_PARAMETERIZED
.from(cause)
.with("String1",1);
```
**From lambda**
```Java
Optional.of(null)
.orElseThrow(MyExceptionType.EXCEPTION_TYPE_PARAMETERIZED
.from(cause)
.with("String1",1))
```