public ExceptionEventArgs(Thread thread, ExceptionRecord record)
			{
				Contract.Requires(thread != null);
				Contract.Requires(record != null);
				this.Thread = thread;
				this.Record = record;
			}
Esempio n. 2
0
        public void PartitionIsBasedOnTheCurrentDay()
        {
            var record = new ExceptionRecord
            {
                StorageMethod = Constants.USE_TABLE_STORAGE
            };

            var refDate = DateTime.Parse("7/4/1776");

            KeyManager.SetKey(record, refDate);

            Assert.Equal("17760704", record.PartitionKey);
        }
        public void StorageManagerStoreSmallErrorTextDirectlyInTable()
        {
            var tableMock = new Mock<ITableClient>();

            var blobMock = new Mock<IBlobClient>();

            var mgr = new StorageManager(tableMock.Object, blobMock.Object);

            var record = new ExceptionRecord
            {
                SerializedError = "Small Error"
            };

            mgr.StoreError(record);

            tableMock.Verify(x => x.Save(It.Is<ExceptionRecord>(r => r == record)));
        }
			public DebugEventResponse OnException(int threadID, ExceptionRecord record)
			{
				var thread = owner.FindThread(threadID);
				if (thread == null)
				{
					Contract.Assert(false, "Received exception from unknown thread.");
					return DebugEventResponse.ContinueUnhandled;
				}

				if (record.Code == Kernel32.EXCEPTION_BREAKPOINT && owner.TryCompleteBreakTask(thread))
				{
					return DebugEventResponse.Break;
				}
				else
				{
					var eventArgs = new ExceptionEventArgs(thread, record);
					return owner.RaiseEvent(owner.ExceptionRaised, eventArgs);
				}
			}
 public void SetUp()
 {
     theRecord = new ExceptionRecord();
 }
        private ObjectValue CreateExceptionObject(ExceptionRecord expRec)
        {
            List<ObjectValue> children = new List<ObjectValue>();

            //message
            ObjectValue message = ObjectValue.CreateObject(
                this,
                new ObjectPath(new string[] { expRec.ExceptionName }),
                "string",
                expRec.ExceptionInfo,
                ObjectValueFlags.Object,
                new ObjectValue[0]);
            message.Name = "Message";
            children.Add(message);

            //inner exception
            if (expRec.InnerExceptionRecord != null)
            {
                ObjectValue innerExp = CreateExceptionObject(expRec.InnerExceptionRecord);
                innerExp.Name = "InnerException";
                children.Add(innerExp);
            }

            //do these for first level only?
            if (expRec == exceptionRecord)
            {
                //stack trace
                List<ObjectValue> stackList = new List<ObjectValue>();
                for (int i = 0; i < magoCallStackFrames.Count; i++)
                {
                    List<ObjectValue> stkValChildren = new List<ObjectValue>();

                    // line
                    ObjectValue stkValLine = ObjectValue.CreateObject(
                        this,
                        new ObjectPath(new string[] { expRec.ExceptionName, "StackTrace", i.ToString(CultureInfo.InvariantCulture) }),
                        "Int",
                        i.ToString(CultureInfo.InvariantCulture),
                        ObjectValueFlags.Object,
                        new ObjectValue[0]);
                    stkValLine.Name = "Line";
                    stkValChildren.Add(stkValLine);

                    ObjectValue stkVal = ObjectValue.CreateObject(
                        this,
                        new ObjectPath(new string[] { expRec.ExceptionName, "StackTrace" }),
                        "Object",
                        magoCallStackFrames[i].FunctionName,
                        ObjectValueFlags.Object,
                        stkValChildren.ToArray());
                    stackList.Add(stkVal);
                }

                ObjectValue stacktrace = ObjectValue.CreateArray(
                    this,
                    new ObjectPath(new string[] {expRec.ExceptionName}),
                    "StackTrace",
                    magoCallStackFrames.Count,
                    ObjectValueFlags.Array,
                    stackList.ToArray());
                stacktrace.Name = "StackTrace";
                children.Add(stacktrace);

                //instance message
                List<ObjectValue> instanceChildren = new List<ObjectValue>();
                ObjectValue instanceMessage = ObjectValue.CreateObject(
                    this,
                    new ObjectPath(new string[] { expRec.ExceptionName, "Instance" }),
                    "string",
                    expRec.ExceptionInfo,
                    ObjectValueFlags.Object | ObjectValueFlags.Public,
                    new ObjectValue[0]);
                instanceMessage.Name = "Message";
                instanceChildren.Add(instanceMessage);

                //instance
                ObjectValue instance = ObjectValue.CreateObject(
                        this,
                        new ObjectPath(new string[] { expRec.ExceptionName }),
                        expRec.ExceptionName,
                        expRec.ExceptionName,
                        ObjectValueFlags.Object,
                        instanceChildren.ToArray());
                instance.Name = "Instance";
                children.Add(instance);
            }

            //parent
            ObjectValue val = ObjectValue.CreateObject(
                this,
                new ObjectPath(new string[] {}),
                expRec.ExceptionName,
                String.Empty,
                ObjectValueFlags.Error, children.ToArray());           

            return val;
        }
        public DDebugExceptionBackTrace(ExceptionRecord rec, DDebugSession session, uint threadId, Debuggee debuggee)
            : base(session, threadId, debuggee)
        {
            this.exceptionRecord = rec;

        }
 public void SetUp()
 {
     theException = new Exception("Test");
     theRecord = ExceptionRecord.FromException(theException);
 }
Esempio n. 9
0
        public void RecordExample()
        {
            // To create a record that implement IDataRecord we start with a record set definition.
            RecordSetDefinition recordSetDefinition = new RecordSetDefinition(
                new ColumnDefinition("ID", SqlDbType.Int),
                new ColumnDefinition("Name", SqlDbType.Char, 50),
                new ColumnDefinition("Description", SqlDbType.NVarChar),
                // This column is not nullable so defaults to true
                new ColumnDefinition("Active", SqlDbType.Bit, isNullable: false, defaultValue: true)
                );

            // Now we can create a record
            IObjectRecord dataRecord = new ObjectRecord(recordSetDefinition, 1, "Test", "This is my test record");

            // Or we can create one with random values
            IObjectRecord randomRecord = new ObjectRecord(recordSetDefinition, true);

            // To create a record that throws an exception we first create a SqlException
            // We can't do this directly, but we can use our prototypes to construct one.

            // SqlExceptions are made from a collection of SqlErrors - which can make like this :
            SqlErrorCollection errorCollection = new SqlErrorCollectionPrototype
            {
                new SqlErrorPrototype(1000, 80, 17, "MyFakeServer",
                                      "Connection Timeout.", "spMySproc", 54)
            };

            SqlException  sqlException    = new SqlExceptionPrototype(errorCollection, "9.0.0.0", Guid.NewGuid());
            IObjectRecord exceptionRecord = new ExceptionRecord(sqlException);

            // We can stick these records into a recordset
            // Note the records must have the same RecordSetDefinition (unless it's an exception record)
            // The final record will through an exception when reached!
            ObjectSet recordSet = new ObjectSet(recordSetDefinition)
            {
                dataRecord,
                randomRecord,
                //exceptionRecord
            };

            // We can add recordsets to an ObjectReader
            ObjectReader reader = new ObjectReader
            {
                recordSet
            };

            // We can also add random record sets - this one has the same definition as the first.
            reader.Add(new RandomSet(recordSetDefinition));

            // We can also fix certain rows values using the column generators arry, a null indicates
            // that the column should us a random value, otherwise a lambda can be supplied - in this case
            // it sets the row to the row number (1 - indexed).
            reader.Add(new RandomSet(recordSetDefinition,
                                     columnGenerators: new Func <int, object>[] { null, row => "Row #" + row }));

            // Whereas this one has a random set of columns (with random types).
            reader.Add(new RandomSet(10));

            // Now that we have a reader we can use it like a normal reader - it even simulates disposal.
            using (IDataReader dataReader = reader)
            {
                int recordset = 1;
                do
                {
                    Trace.Write("Recordset #" + recordset);
                    int rows = 0;
                    while (dataReader.Read())
                    {
                        rows++;
                    }
                    Trace.WriteLine(" - " + rows + " rows.");
                    recordset++;
                } while (dataReader.NextResult());
            }
        }
        private ObjectValue CreateExceptionObject(ExceptionRecord expRec)
        {
            List <ObjectValue> children = new List <ObjectValue>();

            //message
            ObjectValue message = ObjectValue.CreateObject(
                this,
                new ObjectPath(new string[] { expRec.ExceptionName }),
                "string",
                expRec.ExceptionInfo,
                ObjectValueFlags.Object,
                new ObjectValue[0]);

            message.Name = "Message";
            children.Add(message);

            //inner exception
            if (expRec.InnerExceptionRecord != null)
            {
                ObjectValue innerExp = CreateExceptionObject(expRec.InnerExceptionRecord);
                innerExp.Name = "InnerException";
                children.Add(innerExp);
            }

            //do these for first level only?
            if (expRec == exceptionRecord)
            {
                //stack trace
                List <ObjectValue> stackList = new List <ObjectValue>();
                for (int i = 0; i < magoCallStackFrames.Count; i++)
                {
                    List <ObjectValue> stkValChildren = new List <ObjectValue>();

                    // line
                    ObjectValue stkValLine = ObjectValue.CreateObject(
                        this,
                        new ObjectPath(new string[] { expRec.ExceptionName, "StackTrace", i.ToString(CultureInfo.InvariantCulture) }),
                        "Int",
                        i.ToString(CultureInfo.InvariantCulture),
                        ObjectValueFlags.Object,
                        new ObjectValue[0]);
                    stkValLine.Name = "Line";
                    stkValChildren.Add(stkValLine);

                    ObjectValue stkVal = ObjectValue.CreateObject(
                        this,
                        new ObjectPath(new string[] { expRec.ExceptionName, "StackTrace" }),
                        "Object",
                        magoCallStackFrames[i].FunctionName,
                        ObjectValueFlags.Object,
                        stkValChildren.ToArray());
                    stackList.Add(stkVal);
                }

                ObjectValue stacktrace = ObjectValue.CreateArray(
                    this,
                    new ObjectPath(new string[] { expRec.ExceptionName }),
                    "StackTrace",
                    magoCallStackFrames.Count,
                    ObjectValueFlags.Array,
                    stackList.ToArray());
                stacktrace.Name = "StackTrace";
                children.Add(stacktrace);

                //instance message
                List <ObjectValue> instanceChildren = new List <ObjectValue>();
                ObjectValue        instanceMessage  = ObjectValue.CreateObject(
                    this,
                    new ObjectPath(new string[] { expRec.ExceptionName, "Instance" }),
                    "string",
                    expRec.ExceptionInfo,
                    ObjectValueFlags.Object | ObjectValueFlags.Public,
                    new ObjectValue[0]);
                instanceMessage.Name = "Message";
                instanceChildren.Add(instanceMessage);

                //instance
                ObjectValue instance = ObjectValue.CreateObject(
                    this,
                    new ObjectPath(new string[] { expRec.ExceptionName }),
                    expRec.ExceptionName,
                    expRec.ExceptionName,
                    ObjectValueFlags.Object,
                    instanceChildren.ToArray());
                instance.Name = "Instance";
                children.Add(instance);
            }

            //parent
            ObjectValue val = ObjectValue.CreateObject(
                this,
                new ObjectPath(new string[] {}),
                expRec.ExceptionName,
                String.Empty,
                ObjectValueFlags.Error, children.ToArray());

            return(val);
        }
 public DDebugExceptionBackTrace(ExceptionRecord rec, DDebugSession session, uint threadId, Debuggee debuggee)
     : base(session, threadId, debuggee)
 {
     this.exceptionRecord = rec;
 }