From f2f10517db5f2daa567ea1fd16a4219fac8997cc Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 25 May 2023 08:26:37 -0700 Subject: [PATCH] Define our own `ProvisionException` to simplify dependency requirements for OSS. https://github.com/google/error-prone/issues/3897 PiperOrigin-RevId: 535265714 --- .../errorprone/scanner/ErrorProneInjector.java | 12 +++++++++++- .../errorprone/scanner/ErrorProneInjectorTest.java | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneInjector.java b/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneInjector.java index 7a3c79cee5ac..2183023183ad 100644 --- a/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneInjector.java +++ b/check_api/src/main/java/com/google/errorprone/scanner/ErrorProneInjector.java @@ -24,7 +24,6 @@ import com.google.common.collect.MutableClassToInstanceMap; import com.google.errorprone.ErrorProneFlags; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import com.google.inject.ProvisionException; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; @@ -41,6 +40,17 @@ public final class ErrorProneInjector { private final ClassToInstanceMap instances = MutableClassToInstanceMap.create(); + /** Indicates that there was a runtime failure while providing an instance. */ + public static final class ProvisionException extends RuntimeException { + public ProvisionException(String message) { + super(message); + } + + public ProvisionException(String message, Throwable cause) { + super(message, cause); + } + } + public static ErrorProneInjector create() { return new ErrorProneInjector(); } diff --git a/check_api/src/test/java/com/google/errorprone/scanner/ErrorProneInjectorTest.java b/check_api/src/test/java/com/google/errorprone/scanner/ErrorProneInjectorTest.java index 023b9ea30ac2..3d6dc3d02df4 100644 --- a/check_api/src/test/java/com/google/errorprone/scanner/ErrorProneInjectorTest.java +++ b/check_api/src/test/java/com/google/errorprone/scanner/ErrorProneInjectorTest.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; -import com.google.inject.ProvisionException; +import com.google.errorprone.scanner.ErrorProneInjector.ProvisionException; import javax.inject.Inject; import org.junit.Test; import org.junit.runner.RunWith;