Page MenuHomePhorge

Fix crash when upload failed
ClosedPublic

Authored by nannanko on Sat, Jul 6, 5:10 PM.
Tags
None
Referenced Files
F7899: D104.1721596669.diff
Sat, Jul 20, 2:17 PM
Unknown Object (File)
Sat, Jul 20, 4:36 AM
Unknown Object (File)
Sat, Jul 20, 1:57 AM
Unknown Object (File)
Fri, Jul 19, 10:07 PM
Unknown Object (File)
Fri, Jul 19, 9:03 PM
Unknown Object (File)
Fri, Jul 19, 6:16 PM
Unknown Object (File)
Fri, Jul 19, 4:31 PM
Unknown Object (File)
Thu, Jul 18, 11:59 PM
Subscribers
None

Details

Summary

When response isn't an valid json, nlohmann::json::parse() will cause a crash. This fixed it.

Type: fix

Test Plan

Verify that kazv doesn't crash when upload failed.

Diff Detail

Repository
rK kazv
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

There is currently a lack of unit tests, and I'm not sure how to write them at the moment. I will add all related tests for uploading and downloading soon.

src/kazv-io-job.cpp
299–300

Why not use try-catch?

Also Better to log it.

299–300

Don't assume the json body is in valid format. There are plenty of things that can go wrong.

tusooa requested changes to this revision.Sat, Jul 6, 5:41 PM
This revision now requires changes to proceed.Sat, Jul 6, 5:41 PM
  • Use try-catch for exception
tusooa requested changes to this revision.Fri, Jul 12, 7:08 AM
tusooa added inline comments.
src/kazv-io-job.cpp
300–315

Note, your original code doesn't create a default-constructed json. This creates an empty json array instead.

305

should be qCWarning(kazvLog)

309
310
313

should be qCWarning(kazvLog)

src/l10n/en/100-ui.ftl
215

missing translations for cmn-Hans

This revision now requires changes to proceed.Fri, Jul 12, 7:08 AM
  • Add cmn-Hans translations
  • Use qCWarning instead of qDebug
  • Check json format, fix a template call
This revision is now accepted and ready to land.Sat, Jul 13, 9:08 AM
This revision was automatically updated to reflect the committed changes.