you need to check somewhere that the error exists before trying error.stack