text: Title: Validate button shows incomprehensible SyntaxError when the solution trips the timeout limit
  Body: ### Operating system
  
  Arch Linux
  
  ### `nbgrader --version`
  
  ```
  Python version 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801]
  nbgrader version 0.9.1
  ```
  
  ### `jupyterhub --version` (if used with JupyterHub)
  
  4.0.2
  
  ### `jupyter notebook --version` 
  
  7.0.6
  
  ### Expected behavior
  
  Nbgrader should not display a SyntaxError when some internal operation fails.
  
  ### Actual behavior
  
  When a student tries to validate an assignment that gets stuck due to infinite loop, Nbgrader shows this error:
  
  ```
  Validation failed
  Cannot validate: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
  ```
  ![screenshot-2023-11-22@12:08:02](https://github.com/jupyter/nbgrader/assets/1289205/31f7b0d3-27fb-426b-ac5e-39afe20c6c99)
  
  ### Steps to reproduce the behavior
  
  Create an assignment with an infinite loop and click on "Validate":
  
  ```
  while True:
      pass
  ```