Ejemplo n.º 1
0
        static void UncaughtHandler(object sender, UnhandledExceptionEventArgs args)
        {
            Exception e = (Exception)args.ExceptionObject;

            if (e is TargetInvocationException && e.InnerException != null)
            {
                e = e.InnerException;
            }
            using (new WithInvariantCulture()) {
                lock (WriteLock) {
                    ReportNotOk(null);
                    var dic = new CommentDictionaries();
                    dic.Add("message", e.Message);
                    dic.Add("severity", "fail");
                    var meth = e.TargetSite;
                    if (meth != null)
                    {
                        dic.Add("method", string.Format("{0}.{1}", meth.DeclaringType.FullName, meth.Name));
                    }
                    dic.Add("backtrace", e.InnerException == null?e.StackTrace:e.ToString());
                    WriteComment(dic, null, null);
                }
            }
            Environment.Exit(1);
        }
Ejemplo n.º 2
0
        static CommentDictionaries MkCommentDic(bool result, string name, string msg, StackFrame sf)
        {
            var dic = new CommentDictionaries();

            if (msg != null)
            {
                dic.Add("message", msg);
            }
            if (InTodo != null)
            {
                dic.Add("severity", "todo");
                dic.AddExtension("todo", InTodo);
            }
            else
            {
                dic.Add("severity", result?"success":"fail");
            }
            MethodBase meth     = sf.GetMethod();
            var        filename = sf.GetFileName();

            if (filename != null)
            {
                dic.Add("file", MakeRelative(filename));
                var line = sf.GetFileLineNumber();
                dic.Add("line", line);
                var col = sf.GetFileColumnNumber();
                if (col > 0)
                {
                    dic.Add("column", col);
                }
            }
            //if(name!=null) dic.Add("name",name);
            dic.Add("method", string.Format("{0}.{1}", meth.DeclaringType.FullName, meth.Name));
            return(dic);
        }