Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Output an error message for executed command
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
Is there is a way to return error message over mulitple expressions or do I need to split each expression into try & catch.
example code
try
exp1
..... exp 50
end
Expected Output
exp5 NOK
exp 20 NOK
댓글 수: 1
Mohammad Sami
2020년 1월 25일
I am not sure what you mean.
the try catch block will catch any exception. If the exception is in the first line of code, the rest of the code will not be executed. if there is no exception, then catch block will not be run.
답변 (1개)
Walter Roberson
2020년 1월 25일
You need try/catch around the execution of each statement that needs separate handling.
If you are able to put the code for each into a function handle, then you can create a cell array of function handles and then loop
for idx = 1 : length(fncs)
try
fncs{idx}(arguments) ;
catch
report it
end
end
See also the Unit Test framework
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!