use throw exception instead of System.exit for checkError