Skip to content

Commit c1a9d94

Browse files
committed
access to Exception Message and expose TraceBack property
1 parent 20d81f1 commit c1a9d94

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/runtime/pythonexception.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ public PythonException() : base()
3535
if ((_pyType != IntPtr.Zero) && (_pyValue != IntPtr.Zero))
3636
{
3737
string type;
38+
string message;
3839
using (PyObject pyType = new PyObject(_pyType))
3940
using (PyObject pyTypeName = pyType.GetAttr("__name__"))
4041
{
4142
type = pyTypeName.ToString();
4243
}
43-
string message = Runtime.GetManagedString(_pyValue);
44+
45+
using (PyObject pyValue = new PyObject(_pyValue))
46+
{
47+
message = pyValue.ToString();
48+
}
49+
;
50+
4451
_message = type + " : " + message;
4552
}
4653
if (_pyTB != IntPtr.Zero)
@@ -99,6 +106,18 @@ public IntPtr PyValue
99106
get { return _pyValue; }
100107
}
101108

109+
/// <summary>
110+
/// PyTB Property
111+
/// </summary>
112+
///
113+
/// <remarks>
114+
/// Returns the TraceBack as a Python object.
115+
/// </remarks>
116+
117+
public IntPtr PyTB {
118+
get { return _pyTB; }
119+
}
120+
102121
/// <summary>
103122
/// Message Property
104123
/// </summary>

0 commit comments

Comments
 (0)