Fix:Add error handling to pushd and debug functions