Skip to content

Commit 0a248a6

Browse files
committed
Fix line number in warning message
1 parent 47fb051 commit 0a248a6

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

DSPythonNet3/DSPythonNet3Evaluator.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using System.Reflection;
56
using Autodesk.DesignScript.Runtime;
67
using DSPythonNet3.Encoders;
78
using Dynamo.Events;
@@ -290,7 +291,7 @@ public override object Evaluate(
290291
if (!string.IsNullOrEmpty(traceBack))
291292
{
292293
// Throw a new error including trace back info added to the message
293-
throw new InvalidOperationException($"{e.Message} {traceBack}", e);
294+
throw new InvalidOperationException($"{e.Message}\n{traceBack}", e);
294295
}
295296
else
296297
{
@@ -439,19 +440,19 @@ private static void InitializeEncoders()
439440
/// <returns>Trace back message</returns>
440441
private static string GetTraceBack(Exception e)
441442
{
442-
var pythonExc = e as PythonException;
443-
if (!(e is PythonException))
443+
if (e is not PythonException pythonExc)
444444
{
445445
return null;
446446
}
447447

448448
// Return the value of the trace back field (private)
449-
var field = pythonExc.Traceback;
449+
var field = typeof(PythonException).GetMethod("TracebackToString", BindingFlags.NonPublic | BindingFlags.Static);
450450
if (field == null)
451451
{
452452
throw new NotSupportedException(Properties.Resources.InternalErrorTraceBackInfo);
453453
}
454-
return field.ToString();
454+
455+
return (string)field.Invoke(pythonExc, [pythonExc.Traceback]);
455456
}
456457

457458
#region Marshalling

DynamoPythonNet3.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
ProjectSection(SolutionItems) = preProject
1414
nuget.config = nuget.config
1515
pipeline.yml = pipeline.yml
16+
README.md = README.md
1617
EndProjectSection
1718
EndProject
1819
Global

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# DSPythonNet3
22

3-
This projects build the DSPythonNet3 dynamo python engine package.
3+
This project builds the DSPythonNet3 dynamo python engine package.
44

5-
Building the project will output files in `package_output` that can be used to ship as a Dynamo package.
5+
Building the project will output files in `package_output` that can be used to ship as a Dynamo package.
6+
7+
Builds are published to [Jenkins](https://master-5.jenkins.autodesk.com/job/Dynamo/job/DSPythonNet3/job/master/) for each commit to `master`.

0 commit comments

Comments
 (0)