Skip to content

Commit ba77b64

Browse files
author
Melissa Mazura
committed
feat: change the errormessage to show what failure occurs
1 parent a23dd70 commit ba77b64

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

+5
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
299299
private suspend fun uploadContribution(contribution: Contribution) {
300300
if (contribution.localUri == null || contribution.localUri.path == null) {
301301
Timber.e("""upload: ${contribution.media.filename} failed, file path is null""")
302+
contribution.errorMessage = "genuine failure: file path is null"
302303
}
303304
// FP: this is an obvious genuine failure point
304305
// But the actual return point is not here
@@ -387,6 +388,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
387388
// genuine failure, and if we want a more extensive description then
388389
// we have those as well
389390
Timber.e("Stash Upload failed")
391+
contribution.errorMessage = "ambiguous failure: Stash Upload failed"
390392
showFailedNotification(contribution)
391393
contribution.state = Contribution.STATE_FAILED
392394
contribution.chunkInfo = null
@@ -399,6 +401,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
399401
// at least have an exception to work with. And as we have already
400402
// passed one upload step we can be pretty certain this is not a
401403
// genuine failure.
404+
contribution.errorMessage = "failure: upload to stash failed"
402405
Timber.e(exception)
403406
Timber.e("Upload from stash failed for contribution : $filename")
404407
showFailedNotification(contribution)
@@ -419,6 +422,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
419422
// This only gives us a failure, nothing more to work with, so can't say it
420423
// is a genuine failure. This is probably where invalid or missing filename
421424
// will fail
425+
contribution.errorMessage = "ambiguous failure: upload to stash failed"
422426
Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""")
423427
showFailedNotification(contribution)
424428
contribution.state = Contribution.STATE_FAILED
@@ -431,6 +435,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
431435
// Ambiguous in the sense that it is hard to determine from code, but we
432436
// at least have an exception to work with. Might also be here invalid filename
433437
// fails
438+
contribution.errorMessage = "failure: upload failed for contribution"
434439
Timber.e(exception)
435440
Timber.e("Stash upload failed for contribution: $filename")
436441
showFailedNotification(contribution)

0 commit comments

Comments
 (0)