How can I programmatically extract the line number at which a caught error occurred?

7 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Nov 2019
The line number at which a caught error occurred is stored in the MException object. For example, the error number is being extracted from the "mErr" MException object. in the following code:
try
surf
catch mErr
error_line = mErr.stack(end).line;
end

More Answers (0)

Categories

Find more on Exception Handling in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!