0
How do you stop the code from executing (error)?
6 Réponses
+ 3
if it's just code embed it in a try,
if it's loop break statement might work
if it's a function,return statement will stop it's executing further
+ 3
@mei, I think you need to add a link to the troubling code into your original question (on top), until now everyone here are shooting blanks trying to help you, until there is a code for them to see, it will be a mystery what issue you are dealing with.
Create, or open (if you already have it) in Code Playground, save any changes, and share code link by tapping share button on top of code editor, choose copy to clipboard, paste the link on your original question.
P.S. Please do fix your question tags, your recent post indicated JavaScript, then remove Java from tag to not confuse people what language was the question about.
+ 1
Hi Mei
You can use Try statements in both JavaScript and Python
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
http://www.pythonforbeginners.com/error-handling/python-try-and-except
+ 1
For Java, you can put this at the bottom of the catch block:
System.exit(0)
It will exit from the code.
Example:
int a = 5;
int b = 0;
try {
System.out.println(a / b);
}
catch(Exception e) {
System.out.println("(!) Division by zero...");
System.exit(0);
}
0
So what code is it for the return statement?
0
JavaScript