Qt: Errors management

Created on 20 Oct 2016  路  11Comments  路  Source: therecipe/qt

You should not do this:

func X() {
    var err = stdlib.X()
    if err != nil {
        fmt.Println("stdlib.X", err)
    }
}

this ends with logic that half run and half fail. If there is an anomaly, the execution should just stop.

I'm trying to use your repo, but there is so much silenced errors or errors that ends logged, that it's impossible to troubleshoot.

I strongly suggest to use https://github.com/pkg/errors to return all errors back to main and fail on errors instead of silently ignore them.

http://dave.cheney.net/2016/06/12/stack-traces-and-the-errors-package

Most helpful comment

Hey

Yes, I'm sorry I was lazy in regards of error handling.
Also I hadn't really had time to cleanup the code yet (especially tooling) or to implement proper logging, but that shouldn't be an excuse.

However most fatal errors should already result in a call to exit(1)
I will sanitize the error handling and implement a real logger, once I'm done with the docker image.

All 11 comments

Hey

Yes, I'm sorry I was lazy in regards of error handling.
Also I hadn't really had time to cleanup the code yet (especially tooling) or to implement proper logging, but that shouldn't be an excuse.

However most fatal errors should already result in a call to exit(1)
I will sanitize the error handling and implement a real logger, once I'm done with the docker image.

I will sanitize the error handling and implement a real logger, once I'm done with the docker image.

There is a lot out there to use, you should not implement a new one :)

such as https://github.com/Sirupsen/logrus and https://github.com/uber-go/zap

In your case, for your qt/internal speed (usage of reflect) is probably not an issue, maybe github.com/Sirupsen/logrus is a good match for you... and I think it's even the most popular logging Go library.

For error management, https://github.com/pkg/errors is the best thing out there. You create stacktrace like of what are the calls if any errors occurred.

I will help you with some PR whenever I have time and encounter critical bug.

@bclermont I believe he meant that he'll do proper logging in the lib and not create a special package just for logging in the qt binding. If it does make sense, he could implement a Formatter for logrus, for example.
Regarding pkg/errors, I totally agree.

I believe he meant that he'll do proper logging in the lib and not create a special package just for logging in the qt binding

that could be super nice!

@renannprado Thanks, that's what I meant to say :)

@bclermont
Those look really nice, I will definitively use logrus and pkg/errors.
And also thank your for the pull request.

more pain and suffering due to this issue:

$ internal/examples/qml/application qtdeploy build android
file.Load open xxx/qt/internal/examples/qml/application/android/application.keystore: no such file or directory

file.Load open xxx/internal/examples/qml/application/android/application.keystore: no such file or directory

The log is actually a warning (instead of using os.IsExists it read the file every time and log when file don't exists).
and no log/result that can let me know what the result is:
is it success? if yes, why I can't see any file?
is it failure? if yes what is problem?

Sorry, I will start using logrus today as I'm done with the Docker image now.

These are just warnings and can be ignored, if you don't plan to upload the app to some app store (for example Google Play Store).

qtdeploy looks for a password.txt, alias.txt and *.keystore to sign the *.apk.
If it's not found it will use a debug key that can be used to test your app on your phone.

If you want to get your app signed by "qtdeploy" you just have to put these two (or three: alias.txt is optional) files in your "android" folder that should be created by using qtdeploy build android.

You can also manually sign the *.apk with apksigner, here are some infos about that whole topic.
https://developer.android.com/studio/publish/app-signing.html

It also seems like the password and alias are usually stored in keystore.properties and I should probably change that to make it more convenient.

@bclermont
I started to cleanup the tooling and replaced all previous "logging" with logrus.

Thanks

And don't forget return error to caller,!

Haven't looked into pkg/errors yet, but I will start using it when I cleanup qtdeploy :)

What is the status of this? I am having issues with logging as well as console.log calls not showing up at all on certain machines.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ismlsmile picture ismlsmile  路  5Comments

ohenepee picture ohenepee  路  4Comments

adneg picture adneg  路  6Comments

StarAurryon picture StarAurryon  路  5Comments

amlwwalker picture amlwwalker  路  3Comments