Package dev.siroshun.codec4j.api.error
Interface EncodeError
- All Known Subinterfaces:
EncodeError.Failure,EncodeError.FatalError,EncodeError.NotWritableType
@NotNullByDefault
public sealed interface EncodeError
permits EncodeError.Failure, EncodeError.FatalError, EncodeError.NotWritableType
An interface to indicate errors when encoding.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn interface that indicates aEncodeErrorfor custom error type.static interfaceAn interface that indicates aEncodeErrorwhen a fatal error occurred while encoding.static interfaceAn interface that indicates aEncodeErrorwhen the type is not writable. -
Method Summary
Modifier and TypeMethodDescriptiondefault <T> dev.siroshun.jfun.result.Result.Failure<T, EncodeError> Converts thisEncodeErrortoResult.Failure.static EncodeError.FatalErrorfatalError(Throwable cause) Creates aEncodeErrorwhen a fatal error occurred while encoding.static EncodeError.NotWritableTypenotWritableType(Type type) Creates aEncodeErrorwhen the type is not writable.
-
Method Details
-
notWritableType
Creates aEncodeErrorwhen the type is not writable.- Parameters:
type- theTypethat is not writable- Returns:
- a new
EncodeError
-
fatalError
Creates aEncodeErrorwhen a fatal error occurred while encoding.- Parameters:
cause- theThrowablethat caused the error- Returns:
- a new
EncodeError
-
asFailure
Converts thisEncodeErrortoResult.Failure.- Type Parameters:
T- any type- Returns:
- the
Result.Failure
-