Filter löschen
Filter löschen

Display Error message limit of chars

1 Ansicht (letzte 30 Tage)
nad yah
nad yah am 14 Okt. 2015
Kommentiert: dpb am 9 Mär. 2016
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!!

Antworten (1)

dpb
dpb am 14 Okt. 2015
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 Kommentare
Walter Roberson
Walter Roberson am 9 Mär. 2016
260 does include trailing null. 255 + one for drive letter + colon + slash + null
dpb
dpb am 9 Mär. 2016
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).

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by