Azzera filtri
Azzera filtri

Display Error message limit of chars

1 visualizzazione (ultimi 30 giorni)
nad yah
nad yah il 14 Ott 2015
Commentato: dpb il 9 Mar 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!!

Risposte (1)

dpb
dpb il 14 Ott 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 Commenti
Walter Roberson
Walter Roberson il 9 Mar 2016
260 does include trailing null. 255 + one for drive letter + colon + slash + null
dpb
dpb il 9 Mar 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).

Accedi per commentare.

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by