Confusing m-lint behaviour after catch statement
Show older comments
I notice in my own code (and in some professional code, eg. the database toolbox) that it's frequently convenient to use a try/catch block that doesn't make use of the resulting MException object.
For example, if I want to try some "dangerous" statement (say, writing to an database with an unknown connection) but am willing to "just go along" if it fails, I would write something like:
try
cursor = exec(risky_connection, sql)
catch me %#ok
end
Given that m-lint complains about this by default, I presume there's a better construct to handle it... So what is it?
Accepted Answer
More Answers (1)
the cyclist
on 7 Dec 2011
0 votes
Have you read the detailed description of that particular m-lint warning? In a nutshell, it just says that best practice to use the exception identifier in the catch statement, etc.
Personally, I generally just suppress that m-lint warning. :-)
1 Comment
Chad Gilbert
on 7 Dec 2011
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!