01: /*
02: * ErrorCmd.java --
03: *
04: * Implements the "error" command.
05: *
06: * Copyright (c) 1997 Cornell University.
07: * Copyright (c) 1997 Sun Microsystems, Inc.
08: *
09: * See the file "license.terms" for information on usage and
10: * redistribution of this file, and for a DISCLAIMER OF ALL
11: * WARRANTIES.
12: *
13: * RCS: @(#) $Id: ErrorCmd.java,v 1.1.1.1 1998/10/14 21:09:19 cvsadmin Exp $
14: *
15: */
16:
17: package tcl.lang;
18:
19: /*
20: * This class implements the built-in "error" command in Tcl.
21: */
22:
23: class ErrorCmd implements Command {
24:
25: /*
26: *----------------------------------------------------------------------
27: *
28: * cmdProc --
29: *
30: * This procedure is invoked as part of the Command interface to
31: * process the "error" Tcl command. See the user documentation
32: * for details on what it does.
33: *
34: * Results:
35: * None.
36: *
37: * Side effects:
38: * See the user documentation.
39: *
40: *----------------------------------------------------------------------
41: */
42:
43: public void cmdProc(Interp interp, // Current interpreter.
44: TclObject argv[]) // Argument list.
45: throws TclException // A standard Tcl exception.
46: {
47: if (argv.length < 2 || argv.length > 4) {
48: throw new TclNumArgsException(interp, 1, argv,
49: "message ?errorInfo? ?errorCode?");
50: }
51:
52: if (argv.length >= 3) {
53: String errorInfo = argv[2].toString();
54:
55: if (!errorInfo.equals("")) {
56: interp.addErrorInfo(errorInfo);
57: interp.errAlreadyLogged = true;
58: }
59: }
60:
61: if (argv.length == 4) {
62: interp.setErrorCode(argv[3]);
63: }
64:
65: interp.setResult(argv[1]);
66: throw new TclException(TCL.ERROR);
67: }
68:
69: } // end ErrorCmd
|