Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: "Error using ==> dbstop"
Date: Thu, 2 Jul 2009 06:33:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 53
Message-ID: <h2hkat$4m4$1@fred.mathworks.com>
References: <h1vvp9$e75$1@fred.mathworks.com> <4a659c20-07f7-421f-b010-1d7aca2078f6@j19g2000vbp.googlegroups.com> <h29n1b$51j$1@fred.mathworks.com> <h29ubm$kfs$1@fred.mathworks.com> <h2a5po$amq$1@fred.mathworks.com> <MPG.24b27338f102bf719899f2@news.mathworks.com> <h2b74l$n7f$1@fred.mathworks.com> <h2b8a5$cl5$1@fred.mathworks.com> <h2bbii$j2h$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246516381 4804 172.30.248.35 (2 Jul 2009 06:33:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 2 Jul 2009 06:33:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1887645
Xref: news.mathworks.com comp.soft-sys.matlab:552275


"Matthew Simoneau" <matthew@mathworks.com> wrote in message <h2bbii$j2h$1@fred.mathworks.com>...
> To fix this, I just need to change the two lines in matlab/codetools/private/evalmxdom.m from just "catch" to "catch theError".  Using this syntax will prevent it from changing the state of LASTERROR and your code should work fine.

Hi Matthew,
I changed the code in evalmxdom to "catch theError" and  the dbstop error does not occur in lasterror anymore. However, if my testfunction has a real error (e.g. Index exceeds matrix dimensions) it will not be displayed!

e.g.
function test()
a=1;
a(3)        %Error
end

function evaluateTest()
lasterror('reset');
opts.outputDir = fullfile('.');
opts.catchError=true;
publish('test.m', opts);
checkErrors=lasterror
end

running the two programs with "try/catch" in evalmxdom will lead to following command line output:

Index exceeds matrix dimensions.
Error in ==> test at 4
a(3)
checkErrors = 
       message: [1x102 char]
    identifier: 'MATLAB:lineBeyondFileEnd'
         stack: [6x1 struct]

running the programs  with "try/catch theError" in evalmxdom will lead to:
Index exceeds matrix dimensions.
Error in ==> test at 4
a(3)
checkErrors = 
       message: ''
    identifier: ''
         stack: [0x1 struct]

I want to store the last real error in the variable "checkErrors", because I then want to generate an report overview for all checked files (something like that:)

-> test.m        
     Error in ==> test at 4
    Index exceeds matrix dimensions.
-> test2.m
     ok
-> ...

Is there a possibility to access all errors that have occured (not only the last error)? Then I can search for ~MATLAB:lineBeyondFileEnd errors in this struct.

Best regards,

Martin