fix potential crash when error.stack is undefined