Better error handling quick fix

mg.onerror returning non-zero wasn't stopping processing as it was supposed to, fixed.