Changeset 14600


Ignore:
Timestamp:
01/09/14 11:22:38 (10 years ago)
Author:
Mark Evenson
Message:

Signal Java-side exceptions caught in JavaObject?.printObject() as a Lisp error.

From ferada on #abcl: toString() should be caught, otherwise abcl
just stops http://paste.lisp.org/display/140719.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/JavaObject.java

    r13608 r14600  
    360360            return obj.toString();
    361361        final String s;
    362         if(obj != null) {
     362        if (obj != null) {
    363363            Class<?> c = obj.getClass();
    364364            StringBuilder sb
    365365                = new StringBuilder(c.isArray() ? "jarray" : c.getName());
    366366            sb.append(' ');
    367             String ts = obj.toString();
    368             int length = -1;
    369             LispObject stringLength = _JAVA_OBJECT_TO_STRING_LENGTH.symbolValueNoThrow();
    370             if (stringLength instanceof Fixnum) {
    371                 length = Fixnum.getValue(stringLength);
    372             }
    373             if (length < 0) {
    374                 sb.append(ts);
    375             }else if (ts.length() > length) {
    376                 // use '....' to not confuse user with PPRINT conventions
    377                 sb.append(ts.substring(0, length)).append("....");
    378             } else {
    379                 sb.append(ts);
    380             }
    381             s = sb.toString();
     367      try {
     368        String ts = obj.toString();
     369        int length = -1;
     370        LispObject stringLength = _JAVA_OBJECT_TO_STRING_LENGTH.symbolValueNoThrow();
     371        if (stringLength instanceof Fixnum) {
     372          length = Fixnum.getValue(stringLength);
     373        }
     374        if (length < 0) {
     375          sb.append(ts);
     376        } else if (ts.length() > length) {
     377          // use '....' to not confuse user with PPRINT conventions
     378          sb.append(ts.substring(0, length)).append("....");
     379        } else {
     380          sb.append(ts);
     381        }
     382        s = sb.toString();
     383      } catch (Exception e) {
     384        return serror(new JavaException(e));
     385      }
    382386        } else {
    383387            s = "null";
Note: See TracChangeset for help on using the changeset viewer.