Skip to content
Snippets Groups Projects
Verified Commit e9b50b4d authored by BIGARET Sebastien's avatar BIGARET Sebastien
Browse files

Allow InvalidXMLException.name to be null

Note that it was, in fact, already the case potentially since
setName() accepts a null value --but toString() needed to be fixed so
that it does not raise NullPointerException in that case.
parent 0a2f8304
Branches
Tags
No related merge requests found
......@@ -13,8 +13,8 @@ public class InvalidXMLException extends Exception {
private static final long serialVersionUID = 2596435420268330701L;
public enum ELEMENT_TYPE { WORKFLOW, WORKFLOW_INPUT, PROGRAM, PARAMETER, RESULT }
private ELEMENT_TYPE element;
private String name = "unspecified";
private String msg = ""; // TODO remove this, and use Throwable.getMessage() instead
private String name = null;
private String msg = null; // TODO remove this, and use Throwable.getMessage() instead
private boolean fatal = true;
public InvalidXMLException() { super(); }
public InvalidXMLException(String reason) { msg = reason; }
......@@ -30,7 +30,8 @@ public class InvalidXMLException extends Exception {
public String toString()
{
if ( element != null )
return super.toString()+" ["+element+":"+name+"] "
return super.toString()
+ String.format("[%s:%s] ", element, (name!=null ? name : "unspecified"))
+ (msg!=null ? "Reason: "+msg : "");
return super.toString() + (msg!=null ? " Reason: "+msg : "");
......@@ -66,26 +67,26 @@ public class InvalidXMLException extends Exception {
return this;
}
/**
* @return Returns the msg.
* @return Returns the msg. It may be {@code null}.
*/
public String getMsg() {
return msg;
}
/**
* @param msg The msg to set.
* @param msg The msg to set. It may be {@code null}.
*/
public InvalidXMLException setMsg(String msg) {
this.msg = msg;
return this;
}
/**
* @return Returns the name.
* @return Returns the name. It may be {@code null}.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
* @param name The name to set. It may be {@code null}.
*/
public InvalidXMLException setName(String name) {
this.name = name;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment