p5.js version
2.3.2
What is your operating system?
Linux
Web browser and version
firefox 153.0.1
Actual Behavior
When saving a project, if the request fails because of a network error, saveProject() throws a TypeError instead of handling the save failure normally.
the error is:
Cannot read properties of undefined (reading 'status')
this happens because the error handler assumes error.response always exists, but for network errors there is no response.
Expected Behavior
A network error while saving should be handled as a normal save failure without throwing another error.
The user should get the usual save failure handling instead of an unhandled/rejected promise.
Steps to reproduce
Steps:
- open an existing saved project and make some changes.
- disconnect the network or otherwise make the api request fail without returning an http response.
- try to save the project.
- saveProject() rejects with:
Cannot read properties of undefined (reading 'status')
Snippet:
apiClient
.put(`/projects/${state.project.id}`, formParams)
.catch((error) => {
const { response } = error;
if (response.status === 403) {
// ...
}
});
for a network error, error.response is undefined, so accessing response.status throws.
a possible fix would be to check whether response exists before accessing response.status, and handle network errors as a normal save failure.
p5.js version
2.3.2
What is your operating system?
Linux
Web browser and version
firefox 153.0.1
Actual Behavior
When saving a project, if the request fails because of a network error,
saveProject()throws aTypeErrorinstead of handling the save failure normally.the error is:
Cannot read properties of undefined (reading 'status')this happens because the error handler assumes
error.responsealways exists, but for network errors there is no response.Expected Behavior
A network error while saving should be handled as a normal save failure without throwing another error.
The user should get the usual save failure handling instead of an unhandled/rejected promise.
Steps to reproduce
Steps:
Cannot read properties of undefined (reading 'status')
Snippet:
for a network error, error.response is undefined, so accessing response.status throws.
a possible fix would be to check whether response exists before accessing response.status, and handle network errors as a normal save failure.