AaltoSciComp/scicomp-docs

triton/apps/matlab.rst: try/catch in example is probably bad practice

rkdarst opened this issue · 2 comments

In the example on the page, there is a try/catch which (if an error occurs) hides the error message and returns success. This should probably be removed, because it's bad practice and makes debugging much harder.

If any matlab experts have opinions, please let me know here or directly fix it. Otherwise, I will change sometime.

http://scicomp.aalto.fi/triton/apps/matlab.html#simple-serial-script

The reason is that matlab doesn't have proper support for running script files. an error drops it to interactive mode even if running interactively.

So it needs a try/catch and exit(1), otherwise we waste CPU time.

Here is what I have so far. Is this good?

  try
    blah()
  catch ME
    disp(getReport(ME))
    exit(1)
  end

I agree.

Anything that is supposed to run non-interactively with matlab must have somewhere an exit(1) call.