<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A Little Bit on Message Handling</title>
	<atom:link href="http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29955</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 09 Jan 2009 16:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29955</guid>
		<description>Steven-

There is no really good way to do this now.  I will enter an enhancement request.

--Loren</description>
		<content:encoded><![CDATA[<p>Steven-</p>
<p>There is no really good way to do this now.  I will enter an enhancement request.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steven</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29953</link>
		<dc:creator>steven</dc:creator>
		<pubDate>Thu, 08 Jan 2009 18:25:02 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29953</guid>
		<description>I am having issues with throwAsCaller when 
dbstop if error
is engaged.  When the error is thrown, the debugger stops in the code which issues the throwAsCaller, and *not* in the caller, which is what I want. 
From the online help for throwAsCaller:
&quot;In some cases, it is not relevant to show the person running your program the true location that generated an exception, but is better to point to the calling function where the problem really lies...&quot;
This is exactly what I want to do, but dbstop does not do the right thing.  I have tried a number of variations, including using &#039;evalin&#039; to evaluate the error in the caller, etc, but to no avail.

Is there any way to do this? to cause an error to occur in the caller?


thanks much,</description>
		<content:encoded><![CDATA[<p>I am having issues with throwAsCaller when<br />
dbstop if error<br />
is engaged.  When the error is thrown, the debugger stops in the code which issues the throwAsCaller, and *not* in the caller, which is what I want.<br />
From the online help for throwAsCaller:<br />
&#8220;In some cases, it is not relevant to show the person running your program the true location that generated an exception, but is better to point to the calling function where the problem really lies&#8230;&#8221;<br />
This is exactly what I want to do, but dbstop does not do the right thing.  I have tried a number of variations, including using &#8216;evalin&#8217; to evaluate the error in the caller, etc, but to no avail.</p>
<p>Is there any way to do this? to cause an error to occur in the caller?</p>
<p>thanks much,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29941</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 31 Dec 2008 14:19:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29941</guid>
		<description>Ken-

I would recommend reading up on MExceptions (which weren&#039;t available when I wrote this post).  Also, check out throw (and maybe rethrow or throwAsCaller) which allows some control of the stack.

--Loren</description>
		<content:encoded><![CDATA[<p>Ken-</p>
<p>I would recommend reading up on MExceptions (which weren&#8217;t available when I wrote this post).  Also, check out throw (and maybe rethrow or throwAsCaller) which allows some control of the stack.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken F</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29940</link>
		<dc:creator>Ken F</dc:creator>
		<pubDate>Tue, 30 Dec 2008 23:18:18 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-29940</guid>
		<description>I have a question about the error function.  What I would like to do is to display an error message, without displaying any of the stack information.  I want this because I am making an object class, and I don&#039;t want the users to be able to see which functions are throwing the errors.  

What I have tried to do was:

(start of code snippet)

switch error_type
    case 1
        error_text=&#039;??? Some error text&#039;;
    case 2
        error_text=&#039;??? Some error text&#039;;
...
end

%Make the error structure that will be displayed.
serror=struct(&#039;message&#039;, error_text, &#039;identifier&#039;, &#039;&#039;,...
    &#039;stack&#039;, struct(&#039;file&#039;, &#039;&#039;, &#039;name&#039;, &#039;Standard Structure&#039;, &#039;line&#039;, 1));

%Throw the actual error.
error(serror);

(end of code snippet)

On my computer at work, the code does what I want it to do.  But, when I try it at home, the stack information is still being displayed when I use the error function.  

Is there some kind of setting that needs to be set?  

I&#039;ve even tried:

dbstack=struct(&#039;file&#039;, &#039;&#039;, &#039;name&#039;, &#039;Standard Structure&#039;, &#039;line&#039;, 1);

serror=struct(&#039;message&#039;, error_text, &#039;identifier&#039;, &#039;&#039;,...
     &#039;stack&#039;, dbstack);

but I get the same problem.

Any ideas?</description>
		<content:encoded><![CDATA[<p>I have a question about the error function.  What I would like to do is to display an error message, without displaying any of the stack information.  I want this because I am making an object class, and I don&#8217;t want the users to be able to see which functions are throwing the errors.  </p>
<p>What I have tried to do was:</p>
<p>(start of code snippet)</p>
<p>switch error_type<br />
    case 1<br />
        error_text=&#8217;??? Some error text&#8217;;<br />
    case 2<br />
        error_text=&#8217;??? Some error text&#8217;;<br />
&#8230;<br />
end</p>
<p>%Make the error structure that will be displayed.<br />
serror=struct(&#8216;message&#8217;, error_text, &#8216;identifier&#8217;, &#8221;,&#8230;<br />
    &#8216;stack&#8217;, struct(&#8216;file&#8217;, &#8221;, &#8216;name&#8217;, &#8216;Standard Structure&#8217;, &#8216;line&#8217;, 1));</p>
<p>%Throw the actual error.<br />
error(serror);</p>
<p>(end of code snippet)</p>
<p>On my computer at work, the code does what I want it to do.  But, when I try it at home, the stack information is still being displayed when I use the error function.  </p>
<p>Is there some kind of setting that needs to be set?  </p>
<p>I&#8217;ve even tried:</p>
<p>dbstack=struct(&#8216;file&#8217;, &#8221;, &#8216;name&#8217;, &#8216;Standard Structure&#8217;, &#8216;line&#8217;, 1);</p>
<p>serror=struct(&#8216;message&#8217;, error_text, &#8216;identifier&#8217;, &#8221;,&#8230;<br />
     &#8216;stack&#8217;, dbstack);</p>
<p>but I get the same problem.</p>
<p>Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-23541</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 19 Dec 2007 14:13:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-23541</guid>
		<description>Ljubomir-

There is no analogous try-catch way to catch a warning.    You would need to interrogate using the lastwarn function just after you issue the command that might warn.

--Loren</description>
		<content:encoded><![CDATA[<p>Ljubomir-</p>
<p>There is no analogous try-catch way to catch a warning.    You would need to interrogate using the lastwarn function just after you issue the command that might warn.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ljubomir Josifovski</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-23533</link>
		<dc:creator>Ljubomir Josifovski</dc:creator>
		<pubDate>Wed, 19 Dec 2007 11:45:28 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-23533</guid>
		<description>Is there maybe a way to make the warning function (maybe even error functions?) map their action(s) onto throw and so enable the caller to catch them? I run into this in the context of try, rmpath(&#039;may not exist&#039;); catch ... which does not work (ie the program stops if &quot;dbstop if warning&quot; because rmpath warns if the path to be removed is not in the path) because try/catch/throw is unrelated to error/warning functions. I guess I&#039;d like if rmpath worked the way &quot;load&quot; works - example: &quot;try, q=load(&#039;qwe&#039;); disp(&#039;Worked&#039;); catch disp(&#039;Failed&#039;); end&quot;. Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Is there maybe a way to make the warning function (maybe even error functions?) map their action(s) onto throw and so enable the caller to catch them? I run into this in the context of try, rmpath(&#8216;may not exist&#8217;); catch &#8230; which does not work (ie the program stops if &#8220;dbstop if warning&#8221; because rmpath warns if the path to be removed is not in the path) because try/catch/throw is unrelated to error/warning functions. I guess I&#8217;d like if rmpath worked the way &#8220;load&#8221; works &#8211; example: &#8220;try, q=load(&#8216;qwe&#8217;); disp(&#8216;Worked&#8217;); catch disp(&#8216;Failed&#8217;); end&#8221;. Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: F Vinci</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16308</link>
		<dc:creator>F Vinci</dc:creator>
		<pubDate>Tue, 10 Jul 2007 15:30:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16308</guid>
		<description>Thanks for the replies/comments.

Ken, you are right, this is what I want. In essence I&#039;d like
to write out to a file the calling parameters of a function,
from within the function itself.

Ken&#039;s suggestion is a good one, I checked inputname, and it
&quot;almost&quot; does what I want... The problem is that I get the
name of the variable in the caller&#039;s space, and if it&#039;s an
evaluated expression I get nothing at all.

What I&#039;d really really like would be the evaluated arguments that the function got when it was called... 
I think i can explain that as a kind of &quot;stack trace&quot;.
For example, if I use,

function myplot(x,varargin)
plot(x,varargin{:})
magic_argument_printing_to_file_command;
return

then when I call myplot as,

myplot(sin(0:.1:1),&#039;color&#039;,[.5 .7 .3],&#039;linestyle&#039;,&#039;:&#039;)

I&#039;d like to see this written out to a file,
calling parameters for function MYPLOT =&gt; 
 sin(0:.1:1)
 &#039;color&#039;
 [.5 .7 .3]
 &#039;linestyle&#039;
 &#039;:&#039;
Now, assuming that sin(0:.1:1) has already been evaluated within myplot(), i still would find it useful to have the
actual vector written to the file, so that I could recompute all function calls a posteriori...

Loren&#039;s suggestion is interesting, but won&#039;t help me here, I think.

Thanks for any suggestion!</description>
		<content:encoded><![CDATA[<p>Thanks for the replies/comments.</p>
<p>Ken, you are right, this is what I want. In essence I&#8217;d like<br />
to write out to a file the calling parameters of a function,<br />
from within the function itself.</p>
<p>Ken&#8217;s suggestion is a good one, I checked inputname, and it<br />
&#8220;almost&#8221; does what I want&#8230; The problem is that I get the<br />
name of the variable in the caller&#8217;s space, and if it&#8217;s an<br />
evaluated expression I get nothing at all.</p>
<p>What I&#8217;d really really like would be the evaluated arguments that the function got when it was called&#8230;<br />
I think i can explain that as a kind of &#8220;stack trace&#8221;.<br />
For example, if I use,</p>
<p>function myplot(x,varargin)<br />
plot(x,varargin{:})<br />
magic_argument_printing_to_file_command;<br />
return</p>
<p>then when I call myplot as,</p>
<p>myplot(sin(0:.1:1),&#8217;color&#8217;,[.5 .7 .3],&#8217;linestyle&#8217;,':&#8217;)</p>
<p>I&#8217;d like to see this written out to a file,<br />
calling parameters for function MYPLOT =&gt;<br />
 sin(0:.1:1)<br />
 &#8216;color&#8217;<br />
 [.5 .7 .3]<br />
 &#8216;linestyle&#8217;<br />
 &#8216;:&#8217;<br />
Now, assuming that sin(0:.1:1) has already been evaluated within myplot(), i still would find it useful to have the<br />
actual vector written to the file, so that I could recompute all function calls a posteriori&#8230;</p>
<p>Loren&#8217;s suggestion is interesting, but won&#8217;t help me here, I think.</p>
<p>Thanks for any suggestion!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16301</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Thu, 28 Jun 2007 00:02:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16301</guid>
		<description>F Vinci-

It sounds to me like you want to know what args were used by the caller, but from inside the called function. If so, you can use inputname, a built-in matlab function, inside the calling function.

-Ken</description>
		<content:encoded><![CDATA[<p>F Vinci-</p>
<p>It sounds to me like you want to know what args were used by the caller, but from inside the called function. If so, you can use inputname, a built-in matlab function, inside the calling function.</p>
<p>-Ken</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16297</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 22 Jun 2007 15:18:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16297</guid>
		<description>F Vinci-

It would be nice if MATLAB had a more natural way for you to find out the argument list.  For now, you can try this:

dbtype yourfunction 1

will show you the first line of the M-file.  If it&#039;s the usual function line, you can see the argument list there.

--Loren</description>
		<content:encoded><![CDATA[<p>F Vinci-</p>
<p>It would be nice if MATLAB had a more natural way for you to find out the argument list.  For now, you can try this:</p>
<p>dbtype yourfunction 1</p>
<p>will show you the first line of the M-file.  If it&#8217;s the usual function line, you can see the argument list there.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: F Vinci</title>
		<link>http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16296</link>
		<dc:creator>F Vinci</dc:creator>
		<pubDate>Fri, 22 Jun 2007 14:38:17 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/#comment-16296</guid>
		<description>I seek more message wisdom... Specifically, I&#039;d like to get
the variable list of arguments passed into a given function
as a string, to simplify finding/fixing problems in a large application that writes out cascades of files to disk...

Putting it another way, how do I access the arguments of a function call in matlab as a string, without knowing a priori the type/number of the parameters ? I&#039;d like to record in a file the calling argv (argument vector) for every function call, so that I can try to find problems with some optimization results, where things diverge long after some function was called with erroneous values...

dbstack returns a structure that *almost* has what I need... 

I hope someone reading this blog can make me a size matlab programmer!</description>
		<content:encoded><![CDATA[<p>I seek more message wisdom&#8230; Specifically, I&#8217;d like to get<br />
the variable list of arguments passed into a given function<br />
as a string, to simplify finding/fixing problems in a large application that writes out cascades of files to disk&#8230;</p>
<p>Putting it another way, how do I access the arguments of a function call in matlab as a string, without knowing a priori the type/number of the parameters ? I&#8217;d like to record in a file the calling argv (argument vector) for every function call, so that I can try to find problems with some optimization results, where things diverge long after some function was called with erroneous values&#8230;</p>
<p>dbstack returns a structure that *almost* has what I need&#8230; </p>
<p>I hope someone reading this blog can make me a size matlab programmer!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

