Skip to content

Let Unchecked.throwChecked return RuntimeException to improve control flow #324

@leaumar

Description

@leaumar

AS-IS

class Unchecked {
	public static void throwChecked(Throwable t) {
		SeqUtils.sneakyThrow(t);
	}
}
public Object foo() {
	if (condition) {
		return bar();
	} else {
		Unchecked.throwChecked(new Exception());
		return null;
	}
}

TO-BE

class Unchecked {
	public static <T> T throwChecked(Throwable t) {
		SeqUtils.sneakyThrow(t);
		return null;
	}
}
public Object foo() {
	if (condition) {
		return bar();
	} else {
		return Unchecked.throwChecked(new Exception());
	}
}

Versions:

  • jOOλ: 0.9.12
  • Java: 1.8.0.91

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions