No BSD License  

Highlights from
disperror

4.0

4.0 | 1 rating Rate this file 3 Downloads (last 30 days) File Size: 2.74 KB File ID: #10181

disperror

by Jerker Wagberg

 

27 Feb 2006 (Updated 28 Feb 2006)

Display latest error message and where the error occured.

| Watch this File

File Information
Description

Unfortunately, Matlab does not show the location of an error, when the error is rethrown in the catch clause of a try-catch block. This can be very frustrating, since the error can reside several levels deep into possibly unfamiliar code.

DISPERROR will display the error message of the last error, together with the error stack, complete with hyperlinks.

Example:

% function testdisperror
% try
% a=[1 2 3];
% b=a(4711); % Index error
% catch
% % possibly do some housekeeping here
% rethrow(lasterror);
% end
%
% >> testdisperror
% ??? Attempted to access a(4711); index out of bounds ...
%
% >> disperror
% ??? Attempted to access a(4711); index out of bounds ...
% Error in ==> testdisperror at 4

MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements Uses undocumented Matlab function OPENTOLINE.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
01 Mar 2006 Malcolm Wood

Works well, but seems pretty similar to this one:
<a href="http://www.mathworks.com/matlabcentral/fileexchange/loadCategory.do?objectId=115&objectType=Category">Printing MATLAB errors</a>

01 Mar 2006 Malcolm Wood

That link should have been: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9525&objectType=FILE

01 Mar 2006 J Wagberg

Malcolm, you are absolutely right. I would never had created, let alone posted my version, had I known about yours. The search function here at File Exchange makes it a bit hard to check for similar postings though. Do a search for "print error" and you'll see what I mean...

Anyhow, please accept my sincere apologies.

J Wagberg

PS. I'm refraining from spelling out my first name, as a test whether it is some kind of adult content filter that removes my reviews. I have yet to see a review of mine published here!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
development environment Jerker Wagberg 22 Oct 2008 08:17:09
error message rethrow try catch stack line Jerker Wagberg 22 Oct 2008 08:17:09

Contact us at files@mathworks.com