필터 지우기
필터 지우기

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