コード例 #1
0
        public void TestInnerException(string caller_trace, int innerLevel, string excName, string excMessage)
        {
            ExceptionInfoRequest exceptionInfoRequest = new ExceptionInfoRequest();

            exceptionInfoRequest.arguments.threadId = threadId;
            var ret = VSCodeDebugger.Request(exceptionInfoRequest);

            Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace);

            ExceptionInfoResponse exceptionInfoResponse =
                JsonConvert.DeserializeObject <ExceptionInfoResponse>(ret.ResponseStr);


            ExceptionDetails exceptionDetails = exceptionInfoResponse.body.details.innerException[0];

            for (int i = 0; i < innerLevel; ++i)
            {
                exceptionDetails = exceptionDetails.innerException[0];
            }

            if (exceptionDetails.fullTypeName == excName &&
                exceptionDetails.message == excMessage)
            {
                return;
            }

            throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace);
        }
コード例 #2
0
        public void TestExceptionInfo(string caller_trace, string excCategory, string excMode, string excName)
        {
            ExceptionInfoRequest exceptionInfoRequest = new ExceptionInfoRequest();

            exceptionInfoRequest.arguments.threadId = threadId;
            var ret = VSCodeDebugger.Request(exceptionInfoRequest);

            Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace);

            ExceptionInfoResponse exceptionInfoResponse =
                JsonConvert.DeserializeObject <ExceptionInfoResponse>(ret.ResponseStr);

            if (exceptionInfoResponse.body.breakMode == excMode &&
                exceptionInfoResponse.body.exceptionId == excCategory + "/" + excName &&
                exceptionInfoResponse.body.details.fullTypeName == excName)
            {
                return;
            }

            throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace);
        }
コード例 #3
0
 internal void Invalidate()
 {
     this.pendingException = null;
 }
コード例 #4
0
        private bool DoThrow(ThrowArgs args, StringBuilder output)
        {
            SampleThread thread = this.adapter.ThreadManager.GetThread(args.ThreadId);

            if (thread == null)
            {
                output.AppendLine(Invariant($"Unknown thread id '{args.ThreadId}'!"));
                return(false);
            }

            if (this.HasPendingException)
            {
                output.AppendLine("Exception is already pending!");
                return(false);
            }

            if (!args.ExceptionId.Contains("/"))
            {
                output.AppendLine("Expected ExceptionId to be of form 'Category/Exception'!");
                return(false);
            }

            ExceptionBreakMode breakMode = ExceptionBreakMode.Always;

            if (args.Type != null)
            {
                switch (args.Type.Value)
                {
                case ExceptionType.Caught:
                    breakMode = ExceptionBreakMode.Always;
                    break;

                case ExceptionType.Uncaught:
                    breakMode = ExceptionBreakMode.Unhandled;
                    break;

                case ExceptionType.UserUncaught:
                    // UserUncaught means the exception was caught in non-user code, so if JMC is turned off, treat it like any other
                    //  caught exception.
                    breakMode = (this.adapter.IsJustMyCodeOn ?? false) ? ExceptionBreakMode.UserUnhandled : ExceptionBreakMode.Always;
                    break;
                }
            }

            if (this.shouldThrow(args.ExceptionId, breakMode))
            {
                // Our configuration includes this exception - report it to the host
                this.PendingExceptionThread = args.ThreadId;
                this.pendingException       = new ExceptionInfoResponse(
                    exceptionId: args.ExceptionId,
                    breakMode: breakMode,
                    description: args.Description,
                    code: args.Code);
            }
            else
            {
                output.AppendLine(Invariant($"Ignoring exception '{args.ExceptionId}' due to configuration."));
            }

            return(true);
        }