01: /**************************************************************************/
02: /* B O S S A */
03: /* A simple imperative object-oriented research language */
04: /* (c) Daniel Bonniot 1999 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package bossa.util;
12:
13: /**
14: Messages for the user.
15:
16: When the error or warning is conditional, put it inside a 'if'.
17: This is better than passing a boolean to error(),
18: since the latter, forcing evaluation of the string,
19: would slow down compilation.
20: */
21: public final class User {
22: public static UserError error(Located responsible, Exception exn) {
23: return error(responsible, exn.toString());
24: }
25:
26: public static UserError error(Exception exn) {
27: return error(exn.toString());
28: }
29:
30: public static UserError error(Located responsible, String message,
31: String dbgMsg) {
32: if (Debug.powerUser)
33: return error(responsible, message + dbgMsg);
34: else
35: return error(responsible, message);
36: }
37:
38: public static UserError error(Located responsible, String message,
39: Exception dbgExn) {
40: if (Debug.powerUser)
41: return error(responsible, message + " [" + dbgExn + "]");
42: else
43: return error(responsible, message);
44: }
45:
46: public static UserError error(Located responsible, String message) {
47: if (responsible == null)
48: throw new UserError(message);
49: else
50: throw new UserError(responsible, message);
51: }
52:
53: public static UserError error(String message) {
54: throw new UserError(message);
55: }
56:
57: public static void warning(Located responsible, String message) {
58: if (Debug.alwaysDumpStack)
59: Internal.printStackTrace();
60:
61: bossa.modules.Package.currentCompilation.warning(
62: responsible == null ? null : responsible.location(),
63: message);
64: }
65:
66: public static void warning(String message) {
67: warning(null, message);
68: }
69: }
|