Fixes bug in NSError generation