wasCSharpSQLite – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * TclNumArgsException.java |
||
3 | * |
||
4 | * Copyright (c) 1997 Sun Microsystems, Inc. |
||
5 | * |
||
6 | * See the file "license.terms" for information on usage and |
||
7 | * redistribution of this file, and for a DISCLAIMER OF ALL |
||
8 | * WARRANTIES. |
||
9 | * |
||
10 | * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart |
||
11 | * |
||
12 | * RCS @(#) $Id: TclNumArgsException.java,v 1.3 2003/01/12 02:44:28 mdejong Exp $ |
||
13 | * |
||
14 | */ |
||
15 | using System.Text; |
||
16 | namespace tcl.lang |
||
17 | { |
||
18 | |||
19 | /// <summary> This exception is used to report wrong number of arguments in Tcl scripts.</summary> |
||
20 | |||
21 | public class TclNumArgsException : TclException |
||
22 | { |
||
23 | |||
24 | /// <summary> Creates a TclException with the appropiate Tcl error |
||
25 | /// message for having the wring number of arguments to a Tcl command. |
||
26 | /// <p> |
||
27 | /// Example: <pre> |
||
28 | /// |
||
29 | /// if (argv.length != 3) { |
||
30 | /// throw new TclNumArgsException(interp, 1, argv, "option name"); |
||
31 | /// } |
||
32 | /// </pre> |
||
33 | /// |
||
34 | /// </summary> |
||
35 | /// <param name="interp">current Interpreter. |
||
36 | /// </param> |
||
37 | /// <param name="argc">the number of arguments to copy from the offending |
||
38 | /// command to put into the error message. |
||
39 | /// </param> |
||
40 | /// <param name="argv">the arguments of the offending command. |
||
41 | /// </param> |
||
42 | /// <param name="message">extra message to appear in the error message that |
||
43 | /// explains the proper usage of the command. |
||
44 | /// </param> |
||
45 | /// <exception cref=""> TclException is always thrown. |
||
46 | /// </exception> |
||
47 | |||
48 | public TclNumArgsException( Interp interp, int argc, TclObject[] argv, string message ) |
||
49 | : base( TCL.CompletionCode.ERROR ) |
||
50 | { |
||
51 | |||
52 | if ( interp != null ) |
||
53 | { |
||
54 | StringBuilder buff = new StringBuilder( 50 ); |
||
55 | buff.Append( "wrong # args: should be \"" ); |
||
56 | |||
57 | for ( int i = 0; i < argc; i++ ) |
||
58 | { |
||
59 | if ( argv[i].InternalRep is TclIndex ) |
||
60 | { |
||
61 | buff.Append( argv[i].InternalRep.ToString() ); |
||
62 | } |
||
63 | else |
||
64 | { |
||
65 | buff.Append( argv[i].ToString() ); |
||
66 | } |
||
67 | if ( i < ( argc - 1 ) ) |
||
68 | { |
||
69 | buff.Append( " " ); |
||
70 | } |
||
71 | } |
||
72 | if ( ( message != null ) ) |
||
73 | { |
||
74 | buff.Append( " " + message ); |
||
75 | } |
||
76 | buff.Append( "\"" ); |
||
77 | interp.setResult( buff.ToString() ); |
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | } |