title: Exceptions vs. Errors in Matlab
body: <p>Matlab provides two mechanisms for signaling that something has gone wrong: the <code>error</code>function and the language's exception-handling mechanisms <code>MException</code> + <code>try</code>/<code>catch</code>/<code>throw</code>. </p>
  
  <p>It looks like they are largely equivalent: The <code>error</code> function and the <code>MException</code> function have very similar syntax. Errors raised via <code>error()</code> can be caught by a <code>catch</code>, while the error-related tools (like <code>dbstop if error</code> and <code>lasterr</code>) seem to work with exceptions too. </p>
  
  <p>Is there ever a reason to prefer <code>error('Foo:Bar', 'Some human-readable message about bar')</code> to <code>throw(MException('Foo:Bar', 'Some human-readable message'))</code> or vice versa? </p>
  
  <p>(They're both built-ins, so you cannot just open (e.g.) error.m to see if one is a trivial wrapper around the other!)</p>