Class ExceptionalResultUtil
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.handler.util.ExceptionalResultUtil
A utility class used to rethrow exceptions which happened during rpc on the executor side and got sent back to the
original caller.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidrethrowException(@NonNull DataBuf source) Rethrows a serialized exception by wrapping the message and stack trace information into on message and using it as a message in aRPCExecutionException.serializeFirstElement(DataBuf.Mutable target, StackTraceElement @NonNull [] elements) Writes the first stack trace element into the given buffer using the following format: A boolean, indicating if a stack trace element is following, if false no other field will follow.serializeThrowable(DataBuf.Mutable target, @NonNull Throwable throwable) Serializes the given throwable into the given data buffer by writing the name of the exception which was thrown.
-
Constructor Details
-
ExceptionalResultUtil
private ExceptionalResultUtil()
-
-
Method Details
-
serializeThrowable
@NonNull public static @NonNull DataBuf serializeThrowable(@NonNull DataBuf.Mutable target, @NonNull @NonNull Throwable throwable) Serializes the given throwable into the given data buffer by writing the- name of the exception which was thrown.
- optionally the message of the throwable if given.
- first stack trace element.
- Parameters:
target- the buffer to serialize the exception to.throwable- the throwable to serialize into the buffer.- Returns:
- the same buffer used to call the method, for chaining.
-
rethrowException
Rethrows a serialized exception by wrapping the message and stack trace information into on message and using it as a message in aRPCExecutionException.- Parameters:
source- the source buffer to read the information from.- Throws:
RPCExecutionException- always, that is the point of this method.
-
serializeFirstElement
@NonNull private static @NonNull DataBuf serializeFirstElement(@NonNull DataBuf.Mutable target, StackTraceElement @NonNull [] elements) Writes the first stack trace element into the given buffer using the following format:- A boolean, indicating if a stack trace element is following, if false no other field will follow.
- A string, the class name where the exception happened.
- A string, the method name where the exception happened.
- An optional string, the file name where the exception happened.
- An integer, the line number where the exception happened.
- Parameters:
target- the buffer to write the element to.elements- the stack trace elements.- Returns:
- the same buffer used to call the methods, for chaining.
-