Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: "Error using ==> dbstop"
Date: Thu, 2 Jul 2009 10:28:53 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 34
Message-ID: <h2i255$k0u$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> <h2hkat$4m4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246530533 20510 172.30.248.37 (2 Jul 2009 10:28:53 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 2 Jul 2009 10:28:53 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:552320


"Martin "
> 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!

because things are a bit more complicated...
as i said in my 2nd reply
...the LASTERROR should be reset (to the previous value, if any) to not cause such troubles...

1) using the
     catch theError
   keeps the LASTERROR clean...
2) BUT: m-file errors caught during runtime are NOT put into LASTERR but rather
   LASTE (function instrumentAndRun, line #66)
evalstr = [ ...
    'feature(''hotlinks'',0);' ret ...
    'try' ret ...
    'evalin(''base'',getappdata(0,''' tempVar '''));' ret ...
    endCondition ';' ret ...
    'catch laste, end'];     % <- LASTE
3) therefore, to 'reset' LASTERR to the previous value, could do this (nasty) bit
   below line #27
    if options.catchError
        disp(formatError(laste,true))     % <- #27
	warning('off','MATLAB:structOnObject');     % <- LASTE: MException obj
	lasterror(struct(laste));	%#ok
	warning('on','MATLAB:structOnObject');
        beep
    else
        rethrow(laste)
    end

note again: this kludge is necessary due to the fact that the legacy function LASTERR is not an MException obj; nowadays's programs should rely on these objs only...

just a thought...
us