refactor: Safer, more readable user-mismatch detection code in safe-sessions (#29226)
refactor: Safer, more readable user-mismatch detection code in safe-sessions (#29226)

- Add early exit for readability. Less indentation here may make the control flow easier to read.
- Wrap debug info generation in error-suppressing try-except block.

Co-authored-by: Robert Raposa <e2bcbe456d3a3ea25b7a5cf349a80e005d4294e4@edx.org>
arbrandes/edx-platform,edx/edx-platform,arbrandes/edx-platform,angelapper/edx-platform,edx/edx-platform,arbrandes/edx-platform,angelapper/edx-platform,eduNEXT/edx-platform,arbrandes/edx-platform,angelapper/edx-platform,eduNEXT/edx-platform,edx/edx-platform,angelapper/edx-platform,eduNEXT/edx-platform,eduNEXT/edx-platform,edx/edx-platform