Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOException could be hidden in a RuntimeException #6

Open
sv3ndk opened this issue Jan 14, 2021 · 1 comment
Open

IOException could be hidden in a RuntimeException #6

sv3ndk opened this issue Jan 14, 2021 · 1 comment

Comments

@sv3ndk
Copy link

sv3ndk commented Jan 14, 2021

Thanks for open sourcing this!

I am surprised that the main method throws an IOException:

 public String generate() throws IOException {
        Ksuid.KsuidGenerator uid = new Ksuid.KsuidGenerator(random);
        return uid.nextId();
    }

As I understand it, this exception is rethrown because of the ByteArrayOutputStream write operation, although in this case all Streams are internal to the program, so appart from some serious runtime problems, this should never happen, and if it does there's probably not much to do about it at that point.

=> would you welcome a PR with something like:

 public String generate() {
        try {
            Ksuid.KsuidGenerator uid = new Ksuid.KsuidGenerator(random);
            return uid.nextId();
        } catch (IOException e) {
            throw new RuntimeException("unexpected error: failed to write to internal buffers", e);
        }
    }

?

@kevinjam
Copy link

kevinjam commented Dec 3, 2021

Hello @sv3ndk
I agree with you , having a proper return message will help someone to interpret.
Made a PR for that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants