Class RegistrationFailedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
net.neoforged.neoforge.network.registration.RegistrationFailedException
- All Implemented Interfaces:
Serializable
Defines an exception that can be thrown at runtime, if a modder has registered a payload incorrectly.
In practice there are three reasons this exception can be thrown:
- The payload id is already registered.
- The payload id is registered in the wrong namespace.
- Some other unknown reason.
RegistrationFailedException.Reason
enum.
Note: this exception is a runtime exception, meaning that it does not need to be caught. It is not recommended that this exception is caught, since it is a sign of a programming error.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Defines possible reasons for a payload registration to fail.private static interface
Internal interface used to format the error message for a given reason. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ResourceLocation
private final String
private final RegistrationFailedException.Reason
-
Constructor Summary
ConstructorsConstructorDescriptionRegistrationFailedException
(ResourceLocation id, String namespace, Throwable throwable) Creates a new exception with the given parameters.RegistrationFailedException
(ResourceLocation id, String namespace, RegistrationFailedException.Reason reason) Creates a new exception with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetId()
The id of the payload that was being registered.The namespace the payload should be registered in.The reason the registration failed.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
id
-
namespace
-
reason
-
-
Constructor Details
-
RegistrationFailedException
@Internal public RegistrationFailedException(ResourceLocation id, String namespace, RegistrationFailedException.Reason reason) Creates a new exception with the given parameters. The reason can not be unknown.- Parameters:
id
- The id of the payload that was being registered.namespace
- The namespace the payload was being registered in.reason
- The reason the registration failed.
-
RegistrationFailedException
@Internal public RegistrationFailedException(ResourceLocation id, String namespace, Throwable throwable) Creates a new exception with the given parameters. Automatically sets the reason to unknown, and passes the given throwable to the super constructor as reason for the exception.- Parameters:
id
- The id of the payload that was being registered.namespace
- The namespace the payload was being registered in.throwable
- The throwable that caused the registration to fail.
-
-
Method Details
-
getId
The id of the payload that was being registered.- Returns:
- The id of the payload that was being registered.
-
getNamespace
The namespace the payload should be registered in.- Returns:
- The namespace the payload should be registered in.
-
getReason
The reason the registration failed.- Returns:
- The reason the registration failed.
-