Code Monkey home page Code Monkey logo

noexception's People

Contributors

robertvazan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

noexception's Issues

Try construct

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

Sneaky Throws question

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.