Check debug flag instead of environment for stack strace