Prevent MATLAB from displaying full stack on error.
조회 수: 18 (최근 30일)
이전 댓글 표시
EDIT: see answer by Daniel, throwascaller () is what I needed.
Dear all,
Is there a way, when generating an error(), to limit MATLAB output to 'msgIdent' and 'msgString' without the stack information? The reason for this question is that I created a class, overloaded subsref/asgn, and each one of these methods calls yet another method that checks/updates subs. From my prospective, a user who uses invalid subs should only get the error Ident/String that I define, without it to be followed by the whole stack.
I could obviously print the information on stderr and manage the termination by myself, but then usual exceptions management mechanisms could not be used by external code..
Thank you and best regards,
Cedric
댓글 수: 0
채택된 답변
Matt J
2013년 1월 14일
편집: Matt J
2013년 1월 14일
Within SUBSREF/ASGN, you could put the call to the checks/updates inside a TRY...CATCH. Use the ME object returned by the CATCH to determine the error you want to display.
There's no way to get rid of the stack information preceding the call to subsref/subsasgn, I don't think. Only the info after it. I can't imagine why you'd want to get rid of the preceding stack info, though. The user will need that info to trace his/her error.
추가 답변 (1개)
Daniel Shub
2013년 1월 14일
I think with careful use of try/catch and throwascaller you can achieve this. Just be careful since it makes debugging very difficult.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!