1
0
Fork 0

Merge pull request #92 from alexeyOnGitHub/ask-more-exception-improvements

exception messages improvements
master
Bob Carroll 2015-06-13 10:35:00 -07:00
commit 79f44430fa
2 changed files with 12 additions and 10 deletions

View File

@ -582,13 +582,13 @@ public final class Field {
Meta m = getFieldMetadata(name, editmeta);
if (m.type == null)
throw new JiraException("Field metadata is missing a type");
throw new JiraException("Field '" + name + "' is missing metadata type");
if (m.type.equals("array")) {
if (value == null)
value = new ArrayList();
else if (!(value instanceof Iterable))
throw new JiraException("Field expects an Iterable value");
throw new JiraException("Field '" + name + "' expects an Iterable value");
return toArray((Iterable)value, m.items, m.custom);
} else if (m.type.equals("date")) {
@ -597,7 +597,7 @@ public final class Field {
Date d = toDate(value);
if (d == null)
throw new JiraException("Field expects a date value or format is invalid");
throw new JiraException("Field '" + name + "' expects a date value or format is invalid");
SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
return df.format(d);
@ -605,7 +605,7 @@ public final class Field {
if (value == null)
return JSONNull.getInstance();
else if (!(value instanceof Timestamp))
throw new JiraException("Field expects a Timestamp value");
throw new JiraException("Field '" + name + "' expects a Timestamp value");
SimpleDateFormat df = new SimpleDateFormat(DATETIME_FORMAT);
return df.format(value);
@ -656,7 +656,7 @@ public final class Field {
if(!(value instanceof java.lang.Integer) && !(value instanceof java.lang.Double) && !(value
instanceof java.lang.Float) && !(value instanceof java.lang.Long) )
{
throw new JiraException("Field expects a Numeric value");
throw new JiraException("Field '" + name + "' expects a Numeric value");
}
return value;
}

View File

@ -281,18 +281,20 @@ public class Issue extends Resource {
this.transitions = transitions;
}
private Transition getTransition(String id, boolean name) throws JiraException {
private Transition getTransition(String id, boolean isName) throws JiraException {
Transition result = null;
for (Transition transition : transitions) {
if((name && id.equals(transition.getName())
|| (!name && id.equals(transition.getId())))){
if((isName && id.equals(transition.getName())
|| (!isName && id.equals(transition.getId())))){
result = transition;
}
}
if (result == null)
throw new JiraException("Transition was not found.");
if (result == null) {
final String allTransitionNames = Arrays.toString(transitions.toArray());
throw new JiraException("Transition '" + id + "' was not found. Known transitions are:" + allTransitionNames);
}
return result;
}