From 415e303ac283df8d694b311f4f8df08f6e79cf0e Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 16 Apr 2021 06:40:35 +0200 Subject: [pr 2702] finishing the `@StandardException` feature. * rewritten how it works a bit: Now compatible with parent exceptions that don't have the Throwable variants. * rewritten how it works a bit: You can now provide the full constructor only; the rest will forward to it. * fixing up style. * rewrite the docs. --- .../after-delombok/StandardExceptions.java | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'test/transform/resource/after-delombok') diff --git a/test/transform/resource/after-delombok/StandardExceptions.java b/test/transform/resource/after-delombok/StandardExceptions.java index 47453f50..d60fcaf2 100644 --- a/test/transform/resource/after-delombok/StandardExceptions.java +++ b/test/transform/resource/after-delombok/StandardExceptions.java @@ -1,39 +1,36 @@ class EmptyException extends Exception { @java.lang.SuppressWarnings("all") public EmptyException() { + this(null, null); } - @java.lang.SuppressWarnings("all") - public EmptyException(final String message) { - super(message); + public EmptyException(final java.lang.String message) { + this(message, null); } - @java.lang.SuppressWarnings("all") - public EmptyException(final Throwable cause) { - super(cause); + public EmptyException(final java.lang.Throwable cause) { + this(cause != null ? cause.getMessage() : null, cause); } - @java.lang.SuppressWarnings("all") - public EmptyException(final String message, final Throwable cause) { - super(message, cause); + public EmptyException(final java.lang.String message, final java.lang.Throwable cause) { + super(message); + if (cause != null) super.initCause(cause); } } class NoArgsException extends Exception { public NoArgsException() { } - @java.lang.SuppressWarnings("all") - public NoArgsException(final String message) { - super(message); + protected NoArgsException(final java.lang.String message) { + this(message, null); } - @java.lang.SuppressWarnings("all") - public NoArgsException(final Throwable cause) { - super(cause); + protected NoArgsException(final java.lang.Throwable cause) { + this(cause != null ? cause.getMessage() : null, cause); } - @java.lang.SuppressWarnings("all") - public NoArgsException(final String message, final Throwable cause) { - super(message, cause); + protected NoArgsException(final java.lang.String message, final java.lang.Throwable cause) { + super(message); + if (cause != null) super.initCause(cause); } } \ No newline at end of file -- cgit