<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404</link>
    <title>MATLAB Central Newsreader - Error lands in debugger instead?</title>
    <description>Feed for thread: Error lands in debugger instead?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 09 Oct 2007 13:59:22 -0400</pubDate>
      <title>Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395780</link>
      <author>Fred Sigworth</author>
      <description>Is there a better way to debug code?  I run my program, and it halts with an &lt;br&gt;
error.  Then I click on the error statement, go to the editor, set a breakpoint, &lt;br&gt;
and run the program again, this time to halt it so I can look at the variables.&lt;br&gt;
&lt;br&gt;
Why can't a fatal error put me directly into the debugger, as if the program &lt;br&gt;
encountered a breakpoint?  Then I could select which stack frame I wanted, and &lt;br&gt;
look at the variables directly.</description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 14:13:11 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395785</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Fred Sigworth&quot; &amp;lt;fsigworth@mac.com&amp;gt; wrote in message &lt;br&gt;
news:feg1fq$ptf$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Is there a better way to debug code?  I run my program, and it halts with &lt;br&gt;
&amp;gt; an&lt;br&gt;
&amp;gt; error.  Then I click on the error statement, go to the editor, set a &lt;br&gt;
&amp;gt; breakpoint,&lt;br&gt;
&amp;gt; and run the program again, this time to halt it so I can look at the &lt;br&gt;
&amp;gt; variables.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Why can't a fatal error put me directly into the debugger, as if the &lt;br&gt;
&amp;gt; program&lt;br&gt;
&amp;gt; encountered a breakpoint?  Then I could select which stack frame I wanted, &lt;br&gt;
&amp;gt; and&lt;br&gt;
&amp;gt; look at the variables directly.&lt;br&gt;
&lt;br&gt;
Look at &quot;Error Breakpoints&quot; on this page:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/bq4hw4g-1.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_env/bq4hw4g-1.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
If you want to enable this behavior at startup, use DBSTOP in your startup.m &lt;br&gt;
file as described in the last paragraph on that page.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 16:21:08 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395808</link>
      <author>Darik </author>
      <description>&quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;feg29n$ag6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;DBSTOP IF ERROR&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;SNIP&lt;br&gt;
&lt;br&gt;
What about something like this:&lt;br&gt;
&lt;br&gt;
h = figure;&lt;br&gt;
prop = schema.prop(h, 'MyProp', 'mxArray');&lt;br&gt;
prop.SetFunction = @mySetFunction;&lt;br&gt;
set(h, 'MyProp', 'test')&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function val = mySetFunction (h, evt, val)&lt;br&gt;
&lt;br&gt;
%code culminating in error&lt;br&gt;
error ('mySetFunction', 'Error occurred setting property &lt;br&gt;
MyProp')&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Using dbstop if error will result in the debugger stopping &lt;br&gt;
at the SET command, not at the line in the set function &lt;br&gt;
causing the error. Does anyone know if there's a way to &lt;br&gt;
have the debugger stop in the set function?</description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 17:28:10 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395820</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;feg9pk$95b$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Darik  &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote:&lt;br&gt;
&amp;gt;Using dbstop if error will result in the debugger stopping &lt;br&gt;
&amp;gt;at the SET command, not at the line in the set function &lt;br&gt;
&amp;gt;causing the error. Does anyone know if there's a way to &lt;br&gt;
&amp;gt;have the debugger stop in the set function?&lt;br&gt;
&lt;br&gt;
set() is normally a built-in function, not coded in matlab.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Okay, buzzwords only. Two syllables, tops.&quot;  -- Laurie Anderson</description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 18:33:44 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395836</link>
      <author>Darik </author>
      <description>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in &lt;br&gt;
message &amp;lt;fegdna$aeu$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt; In article &amp;lt;feg9pk$95b$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; Darik  &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;Using dbstop if error will result in the debugger &lt;br&gt;
stopping &lt;br&gt;
&amp;gt; &amp;gt;at the SET command, not at the line in the set function &lt;br&gt;
&amp;gt; &amp;gt;causing the error. Does anyone know if there's a way to &lt;br&gt;
&amp;gt; &amp;gt;have the debugger stop in the set function?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; set() is normally a built-in function, not coded in &lt;br&gt;
matlab.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt;    &lt;br&gt;
&lt;br&gt;
Yeah, I know. Using schema.prop to add custom graphics &lt;br&gt;
properties is an undocumented feature. In the code snippet &lt;br&gt;
I posted, the built-in SET function calls the user defined &lt;br&gt;
function mySetFunction.</description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 18:53:51 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395844</link>
      <author>Darik </author>
      <description>&quot;Darik &quot; &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote in message &lt;br&gt;
&amp;lt;feghi8$mnu$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in &lt;br&gt;
&amp;gt; message &amp;lt;fegdna$aeu$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; In article &amp;lt;feg9pk$95b$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; &amp;gt; Darik  &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;Using dbstop if error will result in the debugger &lt;br&gt;
&amp;gt; stopping &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;at the SET command, not at the line in the set &lt;br&gt;
function &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;causing the error. Does anyone know if there's a way &lt;br&gt;
to &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;have the debugger stop in the set function?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; set() is normally a built-in function, not coded in &lt;br&gt;
&amp;gt; matlab.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; -- &lt;br&gt;
&amp;gt; &amp;gt;    &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yeah, I know. Using schema.prop to add custom graphics &lt;br&gt;
&amp;gt; properties is an undocumented feature. In the code &lt;br&gt;
snippet &lt;br&gt;
&amp;gt; I posted, the built-in SET function calls the user &lt;br&gt;
defined &lt;br&gt;
&amp;gt; function mySetFunction.&lt;br&gt;
&lt;br&gt;
Sorry, just realized I wasn't as clear here as I should've &lt;br&gt;
been. I'd like the debugger to stop at the line in &lt;br&gt;
MYSETFUNCTION that causes the error, NOT earlier in the &lt;br&gt;
stack in the parent function that calls the SET function.</description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 19:43:15 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395860</link>
      <author>Yair Altman</author>
      <description>&quot;Darik &quot; &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote in message&lt;br&gt;
&amp;lt;feginv$gp1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Darik &quot; &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;feghi8$mnu$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in &lt;br&gt;
&amp;gt; &amp;gt; message &amp;lt;fegdna$aeu$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; In article &amp;lt;feg9pk$95b$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Darik  &amp;lt;dgambleDEL@uwaterlooDEL.caDEL&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;Using dbstop if error will result in the debugger &lt;br&gt;
&amp;gt; &amp;gt; stopping &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;at the SET command, not at the line in the set &lt;br&gt;
&amp;gt; function &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;causing the error. Does anyone know if there's a way &lt;br&gt;
&amp;gt; to &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;have the debugger stop in the set function?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; set() is normally a built-in function, not coded in &lt;br&gt;
&amp;gt; &amp;gt; matlab.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Yeah, I know. Using schema.prop to add custom graphics &lt;br&gt;
&amp;gt; &amp;gt; properties is an undocumented feature. In the code &lt;br&gt;
&amp;gt; snippet &lt;br&gt;
&amp;gt; &amp;gt; I posted, the built-in SET function calls the user &lt;br&gt;
&amp;gt; defined &lt;br&gt;
&amp;gt; &amp;gt; function mySetFunction.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Sorry, just realized I wasn't as clear here as I should've &lt;br&gt;
&amp;gt; been. I'd like the debugger to stop at the line in &lt;br&gt;
&amp;gt; MYSETFUNCTION that causes the error, NOT earlier in the &lt;br&gt;
&amp;gt; stack in the parent function that calls the SET function.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Schema.prop handlers only receive the object handle and&lt;br&gt;
suggested value as their first 2 args - no evt field. They&lt;br&gt;
also have a generic try-catch mechanism that causes errors&lt;br&gt;
to propagate upward to their caller (=your set call), which&lt;br&gt;
is why you dbstop there. You can trick this by having your&lt;br&gt;
own error-handling code segment, as follows:&lt;br&gt;
&lt;br&gt;
function val = mySetFunction (h, val)&lt;br&gt;
&amp;nbsp;&amp;nbsp;try&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% do something&lt;br&gt;
&amp;nbsp;&amp;nbsp;catch&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;err = lasterror;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;keyboard;  % inspect err struct here&lt;br&gt;
&amp;nbsp;&amp;nbsp;end&lt;br&gt;
&lt;br&gt;
BTW, you can specify additional handler params, as follows:&lt;br&gt;
&lt;br&gt;
prop.SetFunction = {@mySetFunction,data1,data2};&lt;br&gt;
...&lt;br&gt;
function val = mySetFunction(prop,val,d1,d2)&lt;br&gt;
&lt;br&gt;
All this is (as stated above) entirely undocumented and&lt;br&gt;
unsupported. You can see some usage ideas in a few of my&lt;br&gt;
File Exchange submissions&lt;br&gt;
(&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14583&lt;/a&gt;&lt;br&gt;
for example).&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
&lt;a href=&quot;http://ymasoftware.com&quot;&gt;http://ymasoftware.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 09 Oct 2007 21:08:41 -0400</pubDate>
      <title>Re: Error lands in debugger instead?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/157404#395870</link>
      <author>Darik </author>
      <description>&quot;Yair Altman&quot; &amp;lt;altmanyDEL@gmailDEL.comDEL&amp;gt; wrote in message &lt;br&gt;
&amp;lt;feglkj$st2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Schema.prop handlers only receive the object handle and&lt;br&gt;
&amp;gt; suggested value as their first 2 args - no evt field. They&lt;br&gt;
&amp;gt; also have a generic try-catch mechanism that causes errors&lt;br&gt;
&amp;gt; to propagate upward to their caller (=your set call), &lt;br&gt;
which&lt;br&gt;
&amp;gt; is why you dbstop there. You can trick this by having your&lt;br&gt;
&amp;gt; own error-handling code segment, as follows:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function val = mySetFunction (h, val)&lt;br&gt;
&amp;gt;   try&lt;br&gt;
&amp;gt;     % do something&lt;br&gt;
&amp;gt;   catch&lt;br&gt;
&amp;gt;     err = lasterror;&lt;br&gt;
&amp;gt;     keyboard;  % inspect err struct here&lt;br&gt;
&amp;gt;   end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; SNIP &lt;br&gt;
&lt;br&gt;
That'll work! &lt;br&gt;
&lt;br&gt;
I was just writing the example set function from memory, &lt;br&gt;
which is why I messed up the function header. I've actually &lt;br&gt;
learned everything I know about schema.prop objects from &lt;br&gt;
your various posts here on the CSSM, so consider this my &lt;br&gt;
much overdue thanks.</description>
    </item>
  </channel>
</rss>

