Display Error message limit of chars

1 次查看(过去 30 天)
nad yah
nad yah 2015-10-14
评论: dpb 2016-3-9
Hi, I'm writing a long code in matlab 2015a using try and catch, And trying to load many files with using load path. I'm using the catch error message to display the error info very simple example:
try;
load('/path/path/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2222111.txt');
catch err;
disp(err)
end;
but when I looking at the command line it looks like this:
MException with properties:
identifier: 'MATLAB:load:couldNotReadFile'
message: 'Unable to read file '/path/path/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...'
cause: {0x1 cell}
stack: [1x1 struct]
Notice that in the message: field, Matlab doesn't give me the file full path, the path is too long and he gives me 3 points... And I cant find the file like this.. How can I change the limit of chars representation?
Thanks!!

回答(1 个)

dpb
dpb 2015-10-14
You've misdiagnosed the problem. The issue isn't the internal message is too long, it's that you've displayed the MException object err instead of the error message in your catch block. Try something like
...
catch err;
disp(err.identifier)
disp(err.message)
end;
I'd also suggest at least mildly that if this is a real problem your directory nesting is too deep or you're using excessively long file/subdirectory naming conventions, or both...Used to be the Winders OS filelength limit was 255 chars iirc and the above is getting dangerously close methinks plus it's a terrible nuisance albeit I understand these have to have been machine-generated.
  4 个评论
Walter Roberson
Walter Roberson 2016-3-9
260 does include trailing null. 255 + one for drive letter + colon + slash + null
dpb
dpb 2016-3-9
Slow day, Walter???? :)
It still seems to me a peculiar number for a limit...not that it's of an import, just an oddity (to my thinking, anyways).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by