add a meaningful tus error for max file size exceeded

This commit is contained in:
Karol Wypchlo 2021-07-06 14:05:05 +02:00
parent e79eaafd72
commit 447de2cc2a
1 changed files with 7 additions and 0 deletions

View File

@ -54,6 +54,13 @@ const createUploadErrorMessage = (error) => {
return "Server failed to respond to your request, please try again later."; return "Server failed to respond to your request, please try again later.";
} }
// Match the error message to a message returned by TUS when upload exceeds max file size
const matchTusMaxFileSizeError = error.message.match(/upload exceeds maximum size: \d+ > (?<limit>\d+)/);
if (matchTusMaxFileSizeError) {
return `File exceeds size limit of ${bytes(parseInt(matchTusMaxFileSizeError.groups.limit, 10))}`;
}
// TODO: We should add a note "our team has been notified" and have some kind of notification with this error. // TODO: We should add a note "our team has been notified" and have some kind of notification with this error.
return `Critical error, please refresh the application and try again. ${error.message}`; return `Critical error, please refresh the application and try again. ${error.message}`;
}; };