Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use InvalidArgumentsException in BuiltInProcedures
o InvalidArgumentsException is now a generic exception and no longer tied to security o Wrote some utility code for tunneling checked exceptions out of stream pipelines
- Loading branch information
Showing
36 changed files
with
218 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
community/common/src/main/java/org/neo4j/function/UncaughtCheckedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.neo4j.function; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Wrapper around checked exceptions for rethrowing them as runtime exceotions when the signature of the containing method | ||
* cannot be changed to declare them. | ||
* | ||
* Thrown by {@link ThrowingFunction#catchThrown(Class, ThrowingFunction)} | ||
*/ | ||
public class UncaughtCheckedException extends RuntimeException | ||
{ | ||
private final Object source; | ||
|
||
public UncaughtCheckedException( Object source, Throwable cause ) | ||
{ | ||
super( "Uncaught checked exception", cause ); | ||
if ( cause == null ) | ||
{ | ||
throw new IllegalArgumentException( "Expected non-null cause" ); | ||
} | ||
this.source = source; | ||
} | ||
|
||
/** | ||
* Check the that the cause has the given type and if succesful, return it. | ||
* | ||
* @param clazz class object for the desired type of the cause | ||
* @param <E> the desired type of the cause | ||
* @return the underlying cause of this exception but only if it is of desired type E, nothing otherwise | ||
*/ | ||
public <E extends Exception> Optional<E> getCauseIfOfType( Class<E> clazz ) | ||
{ | ||
Throwable cause = getCause(); | ||
if ( clazz.isInstance( cause ) ) | ||
{ | ||
return Optional.of( clazz.cast( cause ) ); | ||
} | ||
else | ||
{ | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public Object source() | ||
{ | ||
return source; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.