Skip to content

Commit d05ede2

Browse files
timfelfangerer
authored andcommitted
differentiate error messages for easier debugging, fix fallback of foreign comparison
1 parent f50076c commit d05ede2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/TruffleObjectBuiltins.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static Object[] unpackForeignArray(Object left, InteropLibrary lib, PForeignToPT
151151
return data;
152152
}
153153
} catch (UnsupportedMessageException | InvalidArrayIndexException e) {
154-
throw new IllegalStateException("object does not unpack as it claims to");
154+
throw new IllegalStateException("object does not unpack to array as it claims to");
155155
}
156156
return null;
157157
}
@@ -212,7 +212,7 @@ Object doComparisonBool(Object left, Object right,
212212
return op.executeObject(right, lib.asBoolean(left));
213213
}
214214
} catch (UnsupportedMessageException e) {
215-
throw new IllegalStateException("object does not unpack as it claims to");
215+
throw new IllegalStateException("object does not unpack to boolean as it claims to");
216216
}
217217
}
218218

@@ -226,7 +226,7 @@ Object doComparisonLong(Object left, Object right,
226226
return op.executeObject(right, lib.asLong(left));
227227
}
228228
} catch (UnsupportedMessageException e) {
229-
throw new IllegalStateException("object does not unpack as it claims to");
229+
throw new IllegalStateException("3object does not unpack to long as it claims to");
230230
}
231231
}
232232

@@ -240,7 +240,7 @@ Object doComparisonDouble(Object left, Object right,
240240
return op.executeObject(right, lib.asDouble(left));
241241
}
242242
} catch (UnsupportedMessageException e) {
243-
throw new IllegalStateException("object does not unpack as it claims to");
243+
throw new IllegalStateException("object does not unpack to double as it claims to");
244244
}
245245
}
246246

@@ -254,7 +254,7 @@ Object doComparisonString(Object left, Object right,
254254
return op.executeObject(right, lib.asString(left));
255255
}
256256
} catch (UnsupportedMessageException e) {
257-
throw new IllegalStateException("object does not unpack as it claims to");
257+
throw new IllegalStateException("object does not unpack to String as it claims to");
258258
}
259259
}
260260

@@ -322,7 +322,7 @@ static Object doForeignArray(Object left, Object right,
322322
try {
323323
rightInt = lib.asInt(right);
324324
} catch (UnsupportedMessageException e) {
325-
throw new IllegalStateException("object does not unpack as it claims to");
325+
throw new IllegalStateException("object does not unpack to index-sized int as it claims to");
326326
}
327327
Object[] unpackForeignArray = unpackForeignArray(left, lib, convert);
328328
if (unpackForeignArray != null) {
@@ -350,7 +350,7 @@ static Object doForeignArrayForeignBoolean(Object left, Object right,
350350
try {
351351
return doForeignArray(left, lib.asBoolean(right) ? 1 : 0, raise, factory, convert, lib);
352352
} catch (UnsupportedMessageException e) {
353-
throw new IllegalStateException("object does not unpack as it claims to");
353+
throw new IllegalStateException("object does not unpack to boolean (to be used as index) as it claims to");
354354
}
355355
}
356356

@@ -429,7 +429,7 @@ Object doComparisonBool(Object left, Object right,
429429
try {
430430
return comparisonNode.executeBool(lib.asBoolean(left), right);
431431
} catch (UnsupportedMessageException e) {
432-
throw new IllegalStateException("object does not unpack as it claims to");
432+
throw new IllegalStateException("object does not unpack to boolean for comparison as it claims to");
433433
}
434434
}
435435

@@ -439,7 +439,7 @@ Object doComparisonLong(Object left, Object right,
439439
try {
440440
return comparisonNode.executeWith(lib.asLong(left), right);
441441
} catch (UnsupportedMessageException e) {
442-
throw new IllegalStateException("object does not unpack as it claims to");
442+
throw new IllegalStateException("object does not unpack to long for comparison as it claims to");
443443
}
444444
}
445445

@@ -449,7 +449,7 @@ Object doComparisonDouble(Object left, Object right,
449449
try {
450450
return comparisonNode.executeWith(lib.asDouble(left), right);
451451
} catch (UnsupportedMessageException e) {
452-
throw new IllegalStateException("object does not unpack as it claims to");
452+
throw new IllegalStateException("object does not unpack to double for comparison as it claims to");
453453
}
454454
}
455455

@@ -462,7 +462,7 @@ Object doComparison(@SuppressWarnings("unused") Object left, Object right,
462462
@SuppressWarnings("unused")
463463
@Fallback
464464
public PNotImplemented doGeneric(Object left, Object right) {
465-
throw new IllegalStateException("object does not unpack as it claims to");
465+
return PNotImplemented.NOT_IMPLEMENTED;
466466
}
467467
}
468468

0 commit comments

Comments
 (0)