01: package com.teamkonzept.lib.math;
02:
03: public class MalformedExpressionException extends Exception {
04:
05: final static int SYNTAX_ERROR = 0;
06: final static int MISSING_OPENING_PAREN = 1;
07: final static int MISSING_CLOSING_PAREN = 2;
08: final static int UNKNOWN_RESULT = 3;
09:
10: int type;
11: int position;
12:
13: public MalformedExpressionException(int type, int position) {
14: this .type = type;
15: this .position = position;
16: }
17:
18: public String toString() {
19: String res;
20: switch (type) {
21: case SYNTAX_ERROR:
22: res = "syntax error";
23: break;
24: case MISSING_OPENING_PAREN:
25: res = "missing opening paren";
26: break;
27: case MISSING_CLOSING_PAREN:
28: res = "missing closing paren";
29: break;
30: case UNKNOWN_RESULT:
31: res = "result has wrong type";
32: break;
33: default:
34: res = "syntax error";
35: }
36: return res + " at position " + position;
37: }
38: }
|