There are a lot of posts with NZEC error. This post is aimed at helping to debug NZEC errors.
- NZEC stands for Non Zero Exit Code.
- Exit codes are codes return by running program to operating system upon either succesful termination(Exit code 0) or termination due to error(Non zero exit code).
- In languages which have exception handling like Java, Python etc we can use exception hadling using try - catch blocks.
- NZEC is a runtime error.
- It mostly occurs when negative array index is accesed or the program which we have written takes up more space than the allocated memory for our program to run.
Code samples and other useful information
Java:
Use exception handling
try{
// code which you think might throw exception
}catch(Exception t){
// you got the exception. Now what??
}
submit your code with a try catch block and see if it is an Exception, if we get WA then we conclude that it is an exception, even now if you get an NZEC that means it not an exception it is an Error(NZEC output) then try the code sample below
try{
new FIRESC().main1();
// code which you think might throw exception
}catch(java.lang.Throwable t){
// you got the exception. Now what??
}
As Throwable class is super class of all error and exception classes in Java we get it caught here by any means. Now try to find the error by replacing statement ājava.lang.Throwable tā with different error classes from this link, now for which error you get a WA judgement that is the error throwing NZEC.
Python:
In python Exception class is the super class of all errors and exceptions.So use the below code sample
try:
#code that may throw an error
except Exception,e:
pass
Then if we get WA then replace Exception with different Exception names till you get a WA and that is the error causing NZEC. Mostly the errors will be due to Memory access or division by zero.
**C: **
NZEC occurs mainly due to
- Infinite Recursion
- Incorrect Memory Access
Please contribute for other languages like C and C++, I think assert will help to some extent.
Happy Debugging!