Add: parameterKey field to ParameterParseException (docstrings included)

This commit is contained in:
Lars Simon Winzer
2026-03-30 13:01:42 +02:00
parent e6b62726bd
commit d990e37a68
2 changed files with 16 additions and 3 deletions
@@ -2,13 +2,26 @@ package ch.unibas.dmi.dbis.cs108.casono.server.network.parser;
/** Exception thrown when a parameter value cannot be converted to the requested type. */
public class ParameterParseException extends RuntimeException {
private final String parameterKey;
/**
* Creates a new parse exception with a root cause.
*
* @param message human-readable description of the parsing failure
* @param parameterKey key for whose value the error occured
* @param cause original exception thrown during parsing
*/
public ParameterParseException(String message, Throwable cause) {
public ParameterParseException(String message, String parameterKey, Throwable cause) {
super(message, cause);
this.parameterKey = parameterKey;
}
/**
* Returns the missing parameter key.
*
* @return key for whose value the error occured
*/
public String getParameterKey() {
return parameterKey;
}
}
@@ -56,7 +56,7 @@ public class RequestParameterAccessor {
try {
return parser.parse(value);
} catch (Exception e) {
throw new ParameterParseException("Error while parsing with specified parser", e);
throw new ParameterParseException("Error while parsing '" + key + "' with specified parser", key, e);
}
}
@@ -94,7 +94,7 @@ public class RequestParameterAccessor {
try {
return parser.parse(value);
} catch (Exception e) {
throw new ParameterParseException("Error while parsing with specified parser", e);
throw new ParameterParseException("Error while parsing '" + key + "' with specified parser", key, e);
}
}