Skip to content

Commit

Permalink
Remove unnecessary constructor from TrinoException
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Feb 29, 2024
1 parent ea8bdb2 commit 7491f72
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 4 additions & 0 deletions core/trino-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@
<code>java.method.addedToInterface</code>
<new>method void io.trino.spi.block.BlockBuilder::resetTo(int)</new>
</item>
<item>
<code>java.method.removed</code>
<old>method void io.trino.spi.TrinoException::&lt;init&gt;(io.trino.spi.ErrorCode, java.lang.String, java.lang.Throwable)</old>
</item>
</differences>
</revapi.differences>
</analysisConfiguration>
Expand Down
12 changes: 1 addition & 11 deletions core/trino-spi/src/main/java/io/trino/spi/TrinoException.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,10 @@ public TrinoException(ErrorCodeSupplier errorCode, String message, Throwable cau
this(errorCode, Optional.empty(), message, cause);
}

public TrinoException(ErrorCode errorCode, String message, Throwable cause)
{
this(errorCode, Optional.empty(), message, cause);
}

public TrinoException(ErrorCodeSupplier errorCodeSupplier, Optional<Location> location, String message, Throwable cause)
{
this(errorCodeSupplier.toErrorCode(), location, message, cause);
}

private TrinoException(ErrorCode errorCode, Optional<Location> location, String message, Throwable cause)
{
super(message, cause);
this.errorCode = requireNonNull(errorCode, "errorCode is null");
this.errorCode = errorCodeSupplier.toErrorCode();
this.location = requireNonNull(location, "location is null");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public record CorruptedDeltaLakeTableHandle(
public TrinoException createException()
{
// Original exception originates from a different place. Create a new exception not to confuse reader with a stacktrace not matching call site.
return new TrinoException(originalException.getErrorCode(), originalException.getMessage(), originalException);
return new TrinoException(originalException::getErrorCode, originalException.getMessage(), originalException);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public record CorruptedIcebergTableHandle(SchemaTableName schemaTableName, Trino
public TrinoException createException()
{
// Original exception originates from a different place. Create a new exception not to confuse reader with a stacktrace not matching call site.
return new TrinoException(originalException.getErrorCode(), originalException.getMessage(), originalException);
return new TrinoException(originalException::getErrorCode, originalException.getMessage(), originalException);
}
}

0 comments on commit 7491f72

Please sign in to comment.