Improve error checking and handling for recordings export (#7647)

* Improve error checking and handling for recordings export

* Cleanup

* Remove order by
This commit is contained in:
Nicolas Mowen
2023-09-02 04:42:33 -06:00
committed by GitHub
parent 36434bb26d
commit db6ee41f3c
2 changed files with 34 additions and 4 deletions

View File

@@ -52,11 +52,17 @@ export default function Export() {
axios
.post(`export/${camera}/start/${start}/end/${end}`, { playback })
.then(() => {
setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false });
.then((response) => {
if (response.status == 200) {
setMessage({ text: 'Successfully started export. View the file in the /exports folder.', error: false });
}
})
.catch((error) => {
setMessage({ text: `Failed to start export: ${error.response.data.message}`, error: true });
if (error.response) {
setMessage({ text: `Failed to start export: ${error.response.data.message}`, error: true });
} else {
setMessage({ text: `Failed to start export: ${error.message}`, error: true });
}
});
};