Merge pull request #945 from SkynetLabs/meaningful-tus-size-error

add a meaningful tus error for max file size exceeded
This commit is contained in:
firyx 2021-07-06 14:42:35 +02:00 committed by GitHub
commit 3f040c7c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.";
}
// 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.
return `Critical error, please refresh the application and try again. ${error.message}`;
};