r52 / PTA

PoE Trade Assistant
GNU General Public License v3.0
21 stars 3 forks source link

[2020-01-28T00:02:31] critical CONSOLE: Uncaught TypeError: Cannot read property 'amount' of null (file:///C:/Users/xxxxx/Documents/PTA_x64/templates/price/index.html:171) - (PWebPage::javaScriptConsoleMessage:24) #23

Open Lolocec4 opened 4 years ago

Lolocec4 commented 4 years ago
         ```

{ "title": "Price", "field": function (entry) { var amount = entry["listing"]["price"]["amount"]; if (amount == null) { amount = ""; } var currency = entry["listing"]["price"]["currency"]; if (currency == null ) { currency = ""; } return amount.toString() + " " + currency; } },


maybe something like this help?
r52 commented 4 years ago

Sorry, this does not help at all. Rather, I would need the item that you were searching for in the first place, and from there find out why the trade site wasn't returning properly formatted data.

Lolocec4 commented 4 years ago

so, its sounds like api callback error and we cant fix it ? but we can miss it, or popup little error message to user ?

Lolocec4 commented 4 years ago

i check lots of items and than sell them to vendor, if i catch this one more time, i pm u with full log

Lolocec4 commented 4 years ago

and , maybe i'm wrong but root of error maybe locates here

    var itemclass = item["rarity"];

    if (item["category"] == "gem" || item["category"] == "prophecy" || item["category"] == "card" || item[
            "category"] == "currency") {
        itemclass = item["category"];
    }

i think , i checkd some unknown itemtype for macro, and 99% this item been corrupted or unidentified

r52 commented 4 years ago

so, its sounds like api callback error and we cant fix it ? but we can miss it, or popup little error message to user ?

If it gets to the javascript at all, that means the trade site returned some resemblance of correct data that's been verified as valid by PTA. The only way the code gets this far and still errors is if this data has bad data nested pretty deep in the results, which seems to be what happened to you in this instance. It could either be a problem on GGG's end or it could be a case that I've never encountered while reverse engineering the API for PTA. Either way, I wouldn't be able to know for sure unless I have the item or the item code and replicate the exact API call to the trade site that returns this bad data that passes validation checks.

and , maybe i'm wrong but root of error maybe locates here

    var itemclass = item["rarity"];

    if (item["category"] == "gem" || item["category"] == "prophecy" || item["category"] == "card" || item[
            "category"] == "currency") {
        itemclass = item["category"];
    }

i think , i checkd some unknown itemtype for macro, and 99% this item been corrupted or unidentified

An unknown itemtype wouldn't stop the price field from being null, which is what the javascript errored on. As far as I know, all results from the trade site with results should have that field, even if the player didn't set a price on their item, which makes this error even more curious.