robertvazan / noexception Goto Github PK
View Code? Open in Web Editor NEWJava library for handling exceptions in concise, unified, and architecturally clean way.
Home Page: https://noexception.machinezoo.com/
License: Apache License 2.0
Java library for handling exceptions in concise, unified, and architecturally clean way.
Home Page: https://noexception.machinezoo.com/
License: Apache License 2.0
Hi,
Thanks for the package. I really find it useful.
Is there any plan to have a try() method similar to the Try in Scala, which handles both checked and unchecked exceptions?
It could be essentially syntactic sugar for
Exceptions.log().get(Exceptions.sneak().supplier(() -> my_throwing_lambda)).orElse(fallback)
Thanks
Best
Hello,
This is not an issue per-se, just wondering why the implementation of ExceptionSmuggler
is not actually more like this for example:
final class ExceptionSmuggler extends CheckedExceptionHandler {
@Override
public RuntimeException handle(Exception exception) {
return sneakyThrow(exception);
}
static <T extends Throwable> RuntimeException sneakyThrow(Throwable t) throws T {
throw (T) t;
}
}
you do want a "sneaky" throw after all here...
also I've actually wondered why CheckedExceptionHandler::function
for example, is not a lambda too, in the form:
public final <T, R> Function<T, R> function(ThrowingFunction<T, R> function) {
return t -> {
try {
return function.apply(t);
} catch (RuntimeException exception) {
throw exception;
} catch (Exception exception) {
throw handle(exception);
}
};
}
And the last nitpick is that those constants in Exceptions
should really be upper-case (it's just easier to read since it's a common convention)... :
private static final Logger LOGGER = LoggerFactory.getLogger(Exceptions.class);
The thing is, we started looking for something like this for our code and while evaluating some other projects on github, your code seems the closest I would accept. I could submit a PR with these changes if you agree with them.
Eugene.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.