Sha256: 8646117f5b8b32c2767938ab06b2eeb6ddec166015249d6e8555e2baffcc7683
Contents?: true
Size: 1.85 KB
Versions: 68
Compression:
Stored size: 1.85 KB
Contents
import java.io.IOException; import java.util.Optional; class ErrorHandling { void handleErrorByThrowingIllegalArgumentException() { throw new IllegalArgumentException(); } void handleErrorByThrowingIllegalArgumentExceptionWithDetailMessage(String message) { throw new IllegalArgumentException(message); } void handleErrorByThrowingAnyCheckedException() throws IOException { throw new IOException(); } void handleErrorByThrowingAnyCheckedExceptionWithDetailMessage(String message) throws IOException { throw new IOException(message); } void handleErrorByThrowingAnyUncheckedException() { throw new NullPointerException(); } void handleErrorByThrowingAnyUncheckedExceptionWithDetailMessage(String message) { throw new NullPointerException(message); } void handleErrorByThrowingCustomCheckedException() throws CustomCheckedException { throw new CustomCheckedException(); } void handleErrorByThrowingCustomCheckedExceptionWithDetailMessage(String message) throws CustomCheckedException { throw new CustomCheckedException(message); } void handleErrorByThrowingCustomUncheckedException() { throw new CustomUncheckedException(); } void handleErrorByThrowingCustomUncheckedExceptionWithDetailMessage(String message) { throw new CustomUncheckedException(message); } Optional<Integer> handleErrorByReturningOptionalInstance(String integer) { if (tryParseInt(integer)) { return Optional.of(Integer.parseInt(integer)); } else { return Optional.empty(); } } private boolean tryParseInt(String integer) { try { Integer.parseInt(integer); return true; } catch (NumberFormatException e) { return false; } } }
Version data entries
68 entries across 68 versions & 1 rubygems