本文整理汇总了C#中tcl.lang.Interp.setErrorCode方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.setErrorCode方法的具体用法?C# Interp.setErrorCode怎么用?C# Interp.setErrorCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.Interp
的用法示例。
在下文中一共展示了Interp.setErrorCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdProc
public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
{
if (argv.Length < 2 || argv.Length > 4)
{
throw new TclNumArgsException(interp, 1, argv, "message ?errorInfo? ?errorCode?");
}
if (argv.Length >= 3)
{
string errorInfo = argv[2].ToString();
if (!errorInfo.Equals(""))
{
interp.addErrorInfo(errorInfo);
interp.errAlreadyLogged = true;
}
}
if (argv.Length == 4)
{
interp.setErrorCode(argv[3]);
}
interp.setResult(argv[1]);
throw new TclException(TCL.CompletionCode.ERROR);
}
示例2: getDouble
internal static double getDouble( Interp interp, string s )
{
int len = s.Length;
bool sign;
int i = 0;
// Skip any leading blanks.
while ( i < len && System.Char.IsWhiteSpace( s[i] ) )
{
i++;
}
if ( i >= len )
{
throw new TclException( interp, "expected floating-point number but got \"" + s + "\"" );
}
char c = s[i];
if ( c == '-' )
{
sign = true;
i += 1;
}
else
{
if ( c == '+' )
{
i += 1;
}
sign = false;
}
StrtodResult res = strtod( s, i );
if ( res.errno != 0 )
{
if ( res.errno == TCL.DOUBLE_RANGE )
{
if ( interp != null )
{
interp.setErrorCode( TclString.newInstance( fpTooBigCode ) );
}
throw new TclException( interp, "floating-point value too large to represent" );
}
else
{
throw new TclException( interp, "expected floating-point number but got \"" + s + "\"" );
}
}
else if ( res.index < len )
{
for ( i = res.index ; i < len ; i++ )
{
if ( !System.Char.IsWhiteSpace( s[i] ) )
{
throw new TclException( interp, "expected floating-point number but got \"" + s + "\"" );
}
}
}
if ( sign )
{
return (double)( -res.value );
}
else
{
return (double)( res.value );
}
}
示例3: getLong
internal static long getLong( Interp interp, string s )
{
int len = s.Length;
bool sign;
int i = 0;
// Skip any leading blanks.
while ( i < len && System.Char.IsWhiteSpace( s[i] ) )
{
i++;
}
if ( i >= len )
{
throw new TclException( interp, "expected integer but got \"" + s + "\"" );
}
char c = s[i];
if ( c == '-' )
{
sign = true;
i += 1;
}
else
{
if ( c == '+' )
{
i += 1;
}
sign = false;
}
StrtoulResult res = strtoul( s, i, 0 );
if ( res.errno < 0 )
{
if ( res.errno == TCL.INTEGER_RANGE )
{
if ( interp != null )
{
interp.setErrorCode( TclString.newInstance( intTooBigCode ) );
}
throw new TclException( interp, "integer value too large to represent" );
}
else
{
throw new TclException( interp, "expected integer but got \"" + s + "\"" + checkBadOctal( interp, s ) );
}
}
else if ( res.index < len )
{
for ( i = res.index ; i < len ; i++ )
{
if ( !System.Char.IsWhiteSpace( s[i] ) )
{
throw new TclException( interp, "expected integer but got \"" + s + "\"" + checkBadOctal( interp, s ) );
}
}
}
if ( sign )
{
return (long)( -res.value );
}
else
{
return (long)( res.value );
}
}
示例4: evalObjv
public static void evalObjv( Interp interp, TclObject[] objv, int length, int flags )
{
Command cmd;
WrappedCommand wCmd = null;
TclObject[] newObjv;
int i;
CallFrame savedVarFrame; //Saves old copy of interp.varFrame
// in case TCL.EVAL_GLOBAL was set.
interp.resetResult();
if ( objv.Length == 0 )
{
return;
}
// If the interpreter was deleted, return an error.
if ( interp.deleted )
{
interp.setResult( "attempt to call eval in deleted interpreter" );
interp.setErrorCode( TclString.newInstance( "CORE IDELETE {attempt to call eval in deleted interpreter}" ) );
throw new TclException( TCL.CompletionCode.ERROR );
}
// Check depth of nested calls to eval: if this gets too large,
// it's probably because of an infinite loop somewhere.
if ( interp.nestLevel >= interp.maxNestingDepth )
{
throw new TclException( interp, "too many nested calls to eval (infinite loop?)" );
}
interp.nestLevel++;
try
{
// Find the procedure to execute this command. If there isn't one,
// then see if there is a command "unknown". If so, create a new
// word array with "unknown" as the first word and the original
// command words as arguments. Then call ourselves recursively
// to execute it.
cmd = interp.getCommand( objv[0].ToString() );
if ( cmd == null )
wCmd = interp.getObjCommand( objv[0].ToString() );
// See if we are running as a slave interpretor, and this is a windows command
if ( cmd == null && wCmd == null && interp.slave != null )
{
wCmd = interp.slave.masterInterp.getObjCommand( objv[0].ToString() );
}
if ( cmd == null && wCmd == null )
{
newObjv = new TclObject[objv.Length + 1];
for ( i = ( objv.Length - 1 ); i >= 0; i-- )
{
newObjv[i + 1] = objv[i];
}
newObjv[0] = TclString.newInstance( "unknown" );
newObjv[0].preserve();
cmd = interp.getCommand( "unknown" );
if ( cmd == null )
{
Debug.Assert( false, "invalid command name \"" + objv[0].ToString() + "\"" );
throw new TclException( interp, "invalid command name \"" + objv[0].ToString() + "\"" );
}
else
{
evalObjv( interp, newObjv, length, 0 );
}
newObjv[0].release();
return;
}
// Finally, invoke the Command's cmdProc.
interp.cmdCount++;
savedVarFrame = interp.varFrame;
if ( ( flags & TCL.EVAL_GLOBAL ) != 0 )
{
interp.varFrame = null;
}
int rc = 0;
if ( cmd != null )
{
if ( cmd.cmdProc( interp, objv ) == TCL.CompletionCode.EXIT )
throw new TclException( TCL.CompletionCode.EXIT );
}
else
{
rc = wCmd.objProc( wCmd.objClientData, interp, objv.Length, objv );
if ( rc != 0 )
{
if ( rc == TCL.TCL_RETURN )
throw new TclException( TCL.CompletionCode.RETURN );
throw new TclException( TCL.CompletionCode.ERROR );
}
}
interp.varFrame = savedVarFrame;
//.........这里部分代码省略.........
示例5: cmdProc
//.........这里部分代码省略.........
p = execReflection( interp, argv, firstWord, argLen );
}
else if ( Util.Unix )
{
p = execUnix( interp, argv, firstWord, argLen );
}
else if ( Util.Windows )
{
p = execWin( interp, argv, firstWord, argLen );
}
else
{
p = execDefault( interp, argv, firstWord, argLen );
}
//note to self : buffer reading should be done in
//a separate thread and not by calling waitFor()
//because a process that is waited for can block
//Wait for the process to finish running,
try
{
p.Start();
p.WaitForExit();
exit = p.ExitCode;
}
catch ( Exception e )
{
throw new TclException( interp, "exception in exec process: " + e.Message );
}
//Make buffer for the results of the subprocess execution
sbuf = new System.Text.StringBuilder();
//read data on stdout stream into result buffer
readStreamIntoBuffer( p.StandardOutput.BaseStream, sbuf );
//if there is data on the stderr stream then append
//this data onto the result StringBuffer
//check for the special case where there is no error
//data but the process returns an error result
errorBytes = readStreamIntoBuffer( p.StandardError.BaseStream, sbuf );
if ( ( errorBytes == 0 ) && ( exit != 0 ) )
{
sbuf.Append( "child process exited abnormally" );
}
//If the last character of the result buffer is a newline, then
//remove the newline character (the newline would just confuse
//things). Finally, we set pass the result to the interpreter.
// Tcl supports lots of child status conditions.
// Unfortunately, we can only find the child's
// exit status using the Java API
if ( exit != 0 )
{
TclObject childstatus = TclList.newInstance();
TclList.append( interp, childstatus, TclString.newInstance( "CHILDSTATUS" ) );
// We don't know how to find the child's pid
TclList.append( interp, childstatus, TclString.newInstance( "?PID?" ) );
TclList.append( interp, childstatus, TclInteger.newInstance( exit ) );
interp.setErrorCode( childstatus );
}
//when the subprocess writes to its stderr stream or returns
//a non zero result we generate an error
if ( ( exit != 0 ) || ( errorBytes != 0 ) )
{
throw new TclException( interp, sbuf.ToString() );
}
//otherwise things went well so set the result
interp.setResult( sbuf.ToString() );
}
catch ( System.IO.IOException e )
{
//if exec fails we end up catching the exception here
throw new TclException( interp, "couldn't execute \"" + argv[firstWord].ToString() + "\": no such file or directory" );
}
catch ( System.Threading.ThreadInterruptedException e )
{
/*
* Do Nothing...
*/
}
return TCL.CompletionCode.RETURN;
}
示例6: DomainError
internal static void DomainError(Interp interp)
{
interp.setErrorCode(TclString.newInstance("ARITH DOMAIN {domain error: argument not in valid range}"));
throw new TclException(interp, "domain error: argument not in valid range");
}
示例7: DoubleTooSmall
internal static void DoubleTooSmall(Interp interp)
{
interp.setErrorCode(TclString.newInstance("ARITH UNDERFLOW {floating-point value too small to represent}"));
throw new TclException(interp, "floating-point value too small to represent");
}
示例8: WideTooLarge
internal static void WideTooLarge( Interp interp )
{
interp.setErrorCode( TclString.newInstance( "ARITH IOVERFLOW {wide value too large to represent}" ) );
throw new TclException( interp, "wide value too large to represent" );
}
示例9: DivideByZero
internal static void DivideByZero(Interp interp)
{
interp.setErrorCode(TclString.newInstance("ARITH DIVZERO {divide by zero}"));
throw new TclException(interp, "divide by zero");
}
示例10: TclPosixException
public TclPosixException( Interp interp, int errno, bool appendPosixMsg, string errorMsg )
: base( TCL.CompletionCode.ERROR )
{
string msg = getPosixMsg( errno );
TclObject threeEltListObj = TclList.newInstance();
TclList.append( interp, threeEltListObj, TclString.newInstance( "POSIX" ) );
TclList.append( interp, threeEltListObj, TclString.newInstance( getPosixId( errno ) ) );
TclList.append( interp, threeEltListObj, TclString.newInstance( msg ) );
interp.setErrorCode( threeEltListObj );
if ( interp != null )
{
if ( appendPosixMsg )
{
interp.setResult( errorMsg + ": " + msg );
}
else
{
interp.setResult( errorMsg );
}
}
}