missing example for the department scope

Bug #1395624 reported by XiaoGuo, Liu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Developer Portal
Confirmed
Medium
David Callé

Bug Description

       // Open weather map API error code can either be a string or int
        QVariant cod = root.toVariant().toMap()["cod"];
        if ((cod.canConvert<QString>() && cod.toString() != "200")
                || (cod.canConvert<unsigned int>() && cod.toUInt() != 200)) {
            throw domain_error(root.toVariant().toMap()["message"].toString().toStdSt
ring());
        }

In fact, there is no "cod" field at all.
Reported from: http://developer.ubuntu.com/scopes/tutorials/adding-departments-to-your-scope/

Revision history for this message
David Callé (davidc3) wrote :

Hmm, the template has probably changed since the tutorial was made. I guess it's crashing the example if the cod field is missing, right?

Changed in developer-ubuntu-com:
assignee: nobody → David Callé (davidc3)
status: New → Confirmed
Revision history for this message
XiaoGuo, Liu (liu-xiao-guo) wrote :

In fact, it does not crash since it is not convertible. The thing is that the code should not be there which makes the code not so good :)

Revision history for this message
David Callé (davidc3) wrote :

Just checked, and there is a "cod" field in the response : http://api.openweathermap.org/data/2.5/forecast/daily?q=London%2Cuk&units=metric&cnt=7

Or maybe you are talking about a different scope or tutorial?

Revision history for this message
XiaoGuo, Liu (liu-xiao-guo) wrote :

Hi David,

Yes, you are right. Maybe this is the one:

http://bazaar.launchpad.net/~davidc3/ubuntu-sdk-tutorials/scope-tutorial-ifixit-departments/view/head:/src/api/client.cpp

In fact, a lot of developers may just simply copy the code, and they do to really check the part of the code. We probably need to review rest of the tutorials as well.

best regards,
Xiaoguo

Changed in developer-ubuntu-com:
importance: Undecided → Medium
Revision history for this message
David Callé (davidc3) wrote :

Unless this is needed before next week, this will be fixed once we have moved out of Wordpress. Changing code snippets (even line-numbering, like in this case) can break the whole page in unexpected ways. I'd prefer to avoid that during these last days of the scopes contest.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.