diff options
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/utilities/optionhandling/WrongParameterValueException.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/utilities/optionhandling/WrongParameterValueException.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/WrongParameterValueException.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/WrongParameterValueException.java index eeb6a9e7..3f34efb7 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/WrongParameterValueException.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/WrongParameterValueException.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2013 + Copyright (C) 2014 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -54,7 +54,7 @@ public class WrongParameterValueException extends ParameterException { * @param cause the cause */ public WrongParameterValueException(Parameter<?> parameter, String read, Throwable cause) { - this("Wrong value of parameter \"" + parameter.getName() + "\".\n" + "Read: " + read + ".\n" + "Expected: " + parameter.getFullDescription() + "\n" + cause.getMessage(), cause); + this("Wrong value of parameter \"" + parameter.getName() + "\".\n" + "Read: " + read + ".\n" + "Expected: " + parameter.getFullDescription() + "\n" + formatCause(cause), cause); } /** @@ -66,7 +66,7 @@ public class WrongParameterValueException extends ParameterException { * @param cause the cause */ public WrongParameterValueException(Parameter<?> parameter, String read, String reason, Throwable cause) { - this("Wrong value of parameter " + parameter.getName() + ".\n" + "Read: " + read + ".\n" + "Expected: " + parameter.getFullDescription() + "\n" + reason + "\n" + cause.getMessage(), cause); + this("Wrong value of parameter " + parameter.getName() + ".\n" + "Read: " + read + ".\n" + "Expected: " + parameter.getFullDescription() + "\n" + reason + "\n" + formatCause(cause), cause); } /** @@ -98,4 +98,21 @@ public class WrongParameterValueException extends ParameterException { public WrongParameterValueException(String message, Throwable e) { super(message, e); } + + /** + * Format the error cause. + * + * @param cause Error cause. + * @return String representation + */ + private static String formatCause(Throwable cause) { + if(cause == null) { + return ""; + } + String message = cause.getMessage(); + if(message != null) { + return message; + } + return cause.toString(); + } } |