Fixed ungraceful failure when failing to connect to web server during file upload.

Review Request #9208 — Created Sept. 22, 2017 and submitted — Latest diff uploaded

Information

Review Board
release-2.5.x
1b7561b...

Reviewers

In the Review Request screen, failing to connect to the web server while
uploading a file using the Update -> Add File dialog would result in a
JavaScript error.

The server response message is parsed as a JSON object. If the server does
not have a response message, which is the case when the connection to the
web server fails, the JSON object parsed from the response message would be
null, resulting in an error when trying to access members of the object
later.

Null checks were added prior to accessing members of the JSON object. This
prevents the JavaScript from simply crashing. A default error message was
added, reading "Unknown Error" if the JSON object is null.

With the fix in place, failing to connect to the web server during a file
upload in the Review Request screen displays "Unknown Error", without any
JavaScript errors.

Ran JSTests.

Tested manually by attempting to upload a file while the server was off.
There were no JavaScript errors, and the displayed error message read
"Unknown Error".

    Loading...