Skip to content

Commit

Permalink
Migrate ProcessorErrorHandler to use XProcessing.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 531027443
  • Loading branch information
wanyingd1996 authored and Dagger Team committed May 10, 2023
1 parent d593e01 commit 738b01a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions java/dagger/hilt/processor/internal/ErrorTypeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@

package dagger.hilt.processor.internal;

import javax.lang.model.element.Element;
import androidx.room.compiler.processing.XElement;

/**
* Exception to throw when a required {@link Element} is or inherits from an error kind.
*
* <p>Includes element to point to for the cause of the error
*/
public final class ErrorTypeException extends RuntimeException {
private final Element badElement;
private final XElement badElement;

public ErrorTypeException(String message, Element badElement) {
public ErrorTypeException(String message, XElement badElement) {
super(message);
this.badElement = badElement;
}

public Element getBadElement() {
public XElement getBadElement() {
return badElement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package dagger.hilt.processor.internal;

import static androidx.room.compiler.processing.XElementKt.isTypeElement;
import static androidx.room.compiler.processing.compat.XConverters.toXProcessing;
import static dagger.internal.codegen.xprocessing.XElements.asTypeElement;

import androidx.room.compiler.processing.XElement;
Expand Down Expand Up @@ -71,9 +70,7 @@ void recordError(Throwable t) {
}
} else if (t instanceof ErrorTypeException) {
ErrorTypeException badInput = (ErrorTypeException) t;
hiltErrors.add(
HiltError.of(
badInput.getMessage(), toXProcessing(badInput.getBadElement(), processingEnv)));
hiltErrors.add(HiltError.of(badInput.getMessage(), badInput.getBadElement()));
} else if (t.getMessage() != null) {
hiltErrors.add(HiltError.of(t.getMessage() + ": " + Throwables.getStackTraceAsString(t)));
} else {
Expand Down

0 comments on commit 738b01a

Please sign in to comment.