Skip to content

Commit

Permalink
Minor refactoring of JacksonException wrt path inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 29, 2024
1 parent 1b0f6ac commit 8634f3e
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/main/java/tools/jackson/core/JacksonException.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ public String getPathReference()

public StringBuilder getPathReference(StringBuilder sb)
{
_appendPathDesc(sb);
return sb;
return _appendPathDesc(sb);
}

/*
Expand Down Expand Up @@ -527,38 +526,40 @@ protected String _buildMessage()
}
}
if (_path != null) {
// 18-Feb-2009, tatu: originally there was a linefeed between
// message and path reference; but unfortunately many systems
// (loggers, junit) seem to assume linefeeds are only added to
// separate stack trace.
sb.append(" (through reference chain: ");
sb = getPathReference(sb);
sb.append(')');
sb = _appendReferenceChain(sb);
}
return sb.toString();
}

@Override
public String toString() { return getClass().getName()+": "+getMessage(); }

/*
/**********************************************************************
/* Internal methods
/**********************************************************************
*/

protected void _appendPathDesc(StringBuilder sb)
protected StringBuilder _appendReferenceChain(StringBuilder sb)
{
if (_path == null) {
return;
}
Iterator<Reference> it = _path.iterator();
while (it.hasNext()) {
sb.append(it.next().toString());
if (it.hasNext()) {
sb.append("->");
sb.append(" (through reference chain: ");
sb = _appendPathDesc(sb);
sb.append(')');
return sb;
}

protected StringBuilder _appendPathDesc(StringBuilder sb)
{
if (_path != null) {
Iterator<Reference> it = _path.iterator();
while (it.hasNext()) {
sb.append(it.next().toString());
if (it.hasNext()) {
sb.append("->");
}
}
}
return sb;
}

}

0 comments on commit 8634f3e

Please sign in to comment.