1

For my simple codehere It seems that the return statement is not needed after the error statement.

  1. Does that mean the function would be early terminated once error is thrown?
  2. If the above is true, what if i do want to process with the rest of function even after an error is thrown. For example, i can still compute c = a - b in my function.
1
  • 4
    1) true. 2) Then don't throw an error, just throw a warning, this will not stop code execution. Commented Apr 6, 2020 at 11:09

1 Answer 1

3
  1. Yes, the error terminates the program.
  2. As suggested by Hoki, use a warning instead.

Note: Your function will throw anyway, if only modifying the code to use warning. This is because the return variable c is not assigned before after the if-statement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.