ProvideDebugExceptionAttribute.cs

Full Listing

View diff from d71588c3c91a

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the Apache License, Version 2.0, please send an email to 
 * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Apache License, Version 2.0.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * ***************************************************************************/
 
using System;
using Microsoft.VisualStudio.Debugger.Interop;
using Microsoft.VisualStudio.Shell;
 
namespace Microsoft.PythonTools {
    /// <summary>
    /// Registers an exception in the Debug->Exceptions window.
    /// 
    /// Supports hierarchy registration but all elements of the hierarchy also need
    /// to be registered independently (to provide their code/state settings).
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple=true)]
    class ProvideDebugExceptionAttribute : RegistrationAttribute {
        private readonly string _engineGuid;
        private readonly string[] _path;
        private int _code, _state;
 
        public ProvideDebugExceptionAttribute(string engineGuid, params string[] path) {
            _engineGuid = engineGuid;
            _path = path;
            _state = (int)(enum_EXCEPTION_STATE.EXCEPTION_JUST_MY_CODE_SUPPORTED | enum_EXCEPTION_STATE.EXCEPTION_STOP_USER_UNCAUGHT);
        }
 
        public int Code {
            get {
                return _code;
            }
            set {
                _code = value;
            }
        }
 
        public int State {
            get {
                return _state;
            }
            set {
                _state = value;
            }
        }
 
        public override void Register(RegistrationAttribute.RegistrationContext context) {
            var engineKey = context.CreateKey("AD7Metrics\\Exception\\" + _engineGuid);
            var key = engineKey;
            foreach (var pathElem in _path) {
                key = key.CreateSubkey(pathElem);
            }
 
            key.SetValue("Code", _code);
            key.SetValue("State", _state);
        }
 
        public override void Unregister(RegistrationAttribute.RegistrationContext context) {
        }
    }
}

Diff from d71588c3c91a

View full listing

@@ -13,6 +13,7 @@
  * ***************************************************************************/
 
 using System;
+using Microsoft.VisualStudio.Debugger.Interop;
 using Microsoft.VisualStudio.Shell;
 
 namespace Microsoft.PythonTools {
@@ -31,6 +32,7 @@
         public ProvideDebugExceptionAttribute(string engineGuid, params string[] path) {
             _engineGuid = engineGuid;
             _path = path;
+            _state = (int)(enum_EXCEPTION_STATE.EXCEPTION_JUST_MY_CODE_SUPPORTED | enum_EXCEPTION_STATE.EXCEPTION_STOP_USER_UNCAUGHT);
         }
 
         public int Code {

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? Click the Pineapple...