public int GetExitCode(ICallerContext context) { object pyObj = ExceptionConverter.ToPython(this); object args; if (!Ops.TryGetAttr(pyObj, SymbolTable.Arguments, out args)) { return(0); } Tuple t = args as Tuple; if (t == null || t.Count == 0) { return(0); } try { return(Converter.ConvertToInt32(t[0])); } catch { } try { Ops.PrintWithDest(context.SystemState, context.SystemState.stderr, t[0]); } catch { } return(1); }
public Tuple exc_info() { if (RawException == null) { return(Tuple.MakeTuple(null, null, null)); } object pyExcep = ExceptionConverter.ToPython(RawException); if (Options.TracebackSupport && RawTraceBack != null) { RawTraceBack.UpdateFromStackTrace(new System.Diagnostics.StackTrace(RawException, true)); } exc_traceback = RawTraceBack; if (pyExcep is StringException) { // string exceptions are special... there tuple looks // like string, argument, traceback instead of // type, instance, traceback StringException se = RawException as StringException; Debug.Assert(se != null); exc_type = pyExcep; exc_value = se.Value; return(Ops.MakeTuple( pyExcep, se.Value, RawTraceBack)); } else { object excType = Ops.GetAttr(DefaultContext.Default, pyExcep, SymbolTable.Class); exc_type = excType; exc_value = pyExcep; return(Ops.MakeTuple( excType, pyExcep, RawTraceBack)); } }