01: package jsint;
02:
03: import jscheme.SchemeException;
04:
05: /**
06: Error routines.
07: **/
08:
09: public class E {
10:
11: /** Throw an error message with an associated object. **/
12: public static Object error(String message, Object x) {
13: throw new SchemeException(message, x);
14: }
15:
16: public static Object error(String message) {
17: return error(message, null);
18: }
19:
20: /** Call error, complaining that we got the wrong type. **/
21: public static Object typeError(String type, Object x) {
22: return error("expected object of type " + type + ", but got: ",
23: x);
24: }
25:
26: /** Print a warning. **/
27: public static Object warn(String message) {
28: Scheme.currentEvaluator().getError().println(
29: "** WARNING: " + message);
30: return message;
31: }
32:
33: /** Print a warning. **/
34: public static Object warn(String message, Object x) {
35: return warn(message + shortStringify(x));
36: }
37:
38: /** It's nice to get an error, but not one large enough to choke EMACS. **/
39: public static String shortStringify(Object x) {
40: String s = U.stringify(x);
41: if (s.length() > 1000)
42: return s.substring(0, 1000) + "...";
43: return s;
44: }
45:
46: }
|