Tutorial - How to debug an NZEC error?

There are a lot of posts with NZEC error. This post is aimed at helping to debug NZEC errors.

  1. NZEC stands for Non Zero Exit Code.
  2. 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).
  3. In languages which have exception handling like Java, Python etc we can use exception hadling using try - catch blocks.
  4. NZEC is a runtime error.
  5. 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


Use exception handling

   // 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

   	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.


In python Exception class is the super class of all errors and exceptions.So use the below code sample

    #code that may throw an error
except Exception,e:

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

  1. Infinite Recursion
  2. Incorrect Memory Access

Please contribute for other languages like C and C++, I think assert will help to some extent.

Happy Debugging!


but what can u do in case of C

Can you tell how to debug it in pascal?, it too have try and exception block.

nice info . Helped me a lot.


Thanks for this it helps!


I generally use


entire main class

} catch(Exception e){}

I got it because I didn’t remove the package declaration in java