mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-09 12:20:16 +01:00
Make write error messages more informational
This commit is contained in:
parent
7b08bb9e1b
commit
d7087c2da5
@ -282,11 +282,12 @@ public class StructureModifier<TField> {
|
|||||||
* @throws FieldAccessException The field doesn't exist, or it cannot be accessed under the current security contraints.
|
* @throws FieldAccessException The field doesn't exist, or it cannot be accessed under the current security contraints.
|
||||||
*/
|
*/
|
||||||
public StructureModifier<TField> write(int fieldIndex, TField value) throws FieldAccessException {
|
public StructureModifier<TField> write(int fieldIndex, TField value) throws FieldAccessException {
|
||||||
if (fieldIndex < 0 || fieldIndex >= data.size())
|
if (fieldIndex < 0)
|
||||||
throw new FieldAccessException("Field index must be within 0 - count",
|
throw new FieldAccessException(String.format("Field index (%s) cannot be negative.", fieldIndex));
|
||||||
new IndexOutOfBoundsException("Out of bounds"));
|
if (fieldIndex >= data.size())
|
||||||
|
throw new FieldAccessException(String.format("Field index out of bounds. (Index: %s, Size: %s)", fieldIndex, data.size()));
|
||||||
if (target == null)
|
if (target == null)
|
||||||
throw new IllegalStateException("Cannot write to a NULL target.");
|
throw new IllegalStateException("Cannot write to a null target");
|
||||||
|
|
||||||
// Use the converter, if it exists
|
// Use the converter, if it exists
|
||||||
Object obj = needConversion() ? converter.getGeneric(getFieldType(fieldIndex), value) : value;
|
Object obj = needConversion() ? converter.getGeneric(getFieldType(fieldIndex), value) : value;
|
||||||
|
Loading…
Reference in New Issue
Block a user