<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python: get error message? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/597778#M80129</link>
    <description>&lt;P&gt;For now, Wrapping the Python call inside a Try( ) is the best option.&amp;nbsp; This is definitely captured as an issue, and it will require some investigation to see what can be done.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Feb 2023 21:16:43 GMT</pubDate>
    <dc:creator>SamGardner</dc:creator>
    <dc:date>2023-02-06T21:16:43Z</dc:date>
    <item>
      <title>Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595728#M79950</link>
      <description>&lt;P&gt;Python integration in jmp is very useful.&lt;/P&gt;&lt;P&gt;For debugging - when I&amp;nbsp;executing a command in Python&amp;nbsp; via&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Python Submit()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and get a return value -1, indicating that something went wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a possibility to get the error message?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. an automatically updated Python variable, which I could get back to JSL via&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Python Get(PythonErrorMessage)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/forums/searchpage/tab/message?q=%23myTop10_2022" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;#myTop10_2022&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;-&amp;gt; JMP 18 : )&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2024 19:03:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595728#M79950</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-25T19:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595808#M79958</link>
      <description>&lt;P&gt;I've been told they are working on it. I was able to build Python code with extra try/except to pass unexpected errors back to JMP as an error message. From &lt;LI-MESSAGE title="Browser Scripting with Python Selenium" uid="485000" url="https://community.jmp.com/t5/Uncharted/Browser-Scripting-with-Python-Selenium/m-p/485000#U485000" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Python Init(); // one-time startup...
// 0: startup 
xrc = Python Execute( {}, {By_ID, By_XPATH, rc},
"\[
try:
    from selenium import webdriver
...
    By_XPATH = By.XPATH
    rc = "ok"
except Exception as e:
    rc = repr(e)
]\"
);

If( xrc != 0 | rc != "ok", Throw( "start up Selenium failed" || Try( ": " || Char( rc ), "" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I agree, that wrapper should be built into the execute interface. And, as I recall, there was some sort of failure that it doesn't catch, but it made debugging much more enjoyable.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 12:47:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595808#M79958</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-01T12:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595872#M79966</link>
      <description>&lt;P&gt;Amazing - thank you so much!&lt;/P&gt;&lt;P&gt;Definitely worth to get&amp;nbsp;into the next release :)&lt;/img&gt;&lt;BR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/32729"&gt;@SamGardner&lt;/a&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the time being, I will replace all my &lt;STRONG&gt;Python Submit()&lt;/STRONG&gt;&amp;nbsp;with &lt;STRONG&gt;Python Try()&lt;/STRONG&gt; :)&lt;/img&gt;&lt;BR /&gt;Please not the single additional indentation in he &lt;STRONG&gt;code&lt;/STRONG&gt; to match the &lt;STRONG&gt;try&lt;/STRONG&gt;&amp;nbsp;in the Python Try function - especially as this implementation of error forwarding doesn't have a chance to react on &lt;EM&gt;&lt;STRONG&gt;indentation&lt;/STRONG&gt; &lt;/EM&gt;errors (as well as all the other errors which are detected &lt;EM&gt;before&lt;/EM&gt; executing the code *).&lt;BR /&gt;I guess that Jmp team will implement it in a more robust way ...&lt;BR /&gt;&lt;BR /&gt;*) So, if you have an error message like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1675263255017.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49696i1C1301D3F2721C33/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1675263255017.png" alt="hogi_0-1675263255017.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;it could be an indentation error. Beware of using the &lt;STRONG&gt;Reformat Script&lt;/STRONG&gt; function ;)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Python Init();

Python Try = Function( {code},
xrc = Python Execute(
		{},
		{rc},
"try:" || code || "\[
	rc = "ok"
except Exception as e:
	rc = repr(e)
]\"
	);
	If( xrc != 0 | rc != "ok",
		Throw( "Python error !
" || Try( Char( rc ), "" ) )
	);
);

Python Try( "
	print(0)" );

Python Try( "
	print(xxx)" );
	
Python Term()&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 14:55:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595872#M79966</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-02-01T14:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595875#M79967</link>
      <description>&lt;P&gt;Another trick for Python Debugging:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Python Submit("\[
Lorem ipsum dolor sit ametERROR IS HERE, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
]\")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;split the code off by including it as a package:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Python Submit("&lt;BR /&gt;import loremIpsum as li
li()&lt;BR /&gt;");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then you can import the same package in parallel into a&amp;nbsp;&lt;STRONG&gt;pythonText.py&lt;/STRONG&gt;&amp;nbsp;file and check if all the functions run as expected.&lt;/P&gt;&lt;P&gt;Then JSL debugging can be reduced to the interface part.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Additional benefit:&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can edit the code of the loremIpsum package in your preferred Python text editor with syntax highlighting and other gimmicks.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 14:24:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/595875#M79967</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-02-01T14:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/597778#M80129</link>
      <description>&lt;P&gt;For now, Wrapping the Python call inside a Try( ) is the best option.&amp;nbsp; This is definitely captured as an issue, and it will require some investigation to see what can be done.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 21:16:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/597778#M80129</guid>
      <dc:creator>SamGardner</dc:creator>
      <dc:date>2023-02-06T21:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/724701#M90777</link>
      <description>&lt;P&gt;As Craige has indicated, use of try: except: is the best option. &amp;nbsp;It's also great programming practice to make a habit. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very soon we will be unveiling JMP 18 in Manchester. &amp;nbsp;I believe you will be pleasantly surprised. &amp;nbsp;Significant effort has been put into updating and improving the Python integration.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stay tuned...&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 16:19:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/724701#M90777</guid>
      <dc:creator>Paul_Nelson</dc:creator>
      <dc:date>2024-02-19T16:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Python: get error message?</title>
      <link>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/730539#M91351</link>
      <description>&lt;P&gt;Very cool the new smooth integration of Python in Jmp.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 18:01:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Python-get-error-message/m-p/730539#M91351</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-03-07T18:01:16Z</dc:date>
    </item>
  </channel>
</rss>

