Elitezen / open-trivia-db-wrapper

A wrapper for the Open Trivia Database API. Built with TypeScript, works with VanillaJS.
https://opentdb.com
MIT License
6 stars 3 forks source link

Cannot read properties of undefined (reading 'text') #11

Closed aral closed 4 months ago

aral commented 8 months ago

I’m sometimes seeing a crash – assuming when the Open Trivia DB returns an error. (Present in latest 2.0.5 although it was also there with the 1.x version I was running prior to updating).

Stack trace:

While running new OpenTDBError
in /var/home/aral/Projects/kitten/app/examples/trivia module [open-trivia-db](https://www.npmjs.com/package/open-trivia-db) /dist/src/Classes/OpenTDBError.js (line 25, column 45)
While running /var/home/aral/Projects/kitten/app/examples/trivia module [open-trivia-db](https://www.npmjs.com/package/open-trivia-db) /dist/src/Functions/getQuestions.js:104:27
While running step
in /var/home/aral/Projects/kitten/app/examples/trivia module [open-trivia-db](https://www.npmjs.com/package/open-trivia-db) /dist/src/Functions/getQuestions.js (line 33, column 23)
While running Object.throw
in /var/home/aral/Projects/kitten/app/examples/trivia module [open-trivia-db](https://www.npmjs.com/package/open-trivia-db) /dist/src/Functions/getQuestions.js (line 14, column 53)
While running rejected
in /var/home/aral/Projects/kitten/app/examples/trivia module [open-trivia-db](https://www.npmjs.com/package/open-trivia-db) /dist/src/Functions/getQuestions.js (line 6, column 65)
While running process.processTicksAndRejections
in node:internal/process/task_queues (line 95, column 5)

The relevant code is below (error is undefined):

/**
 * @class OpenTDB error constructor
 * @private
 */
var OpenTDBError = /** @class */ (function (_super) {
    __extends(OpenTDBError, _super);
    function OpenTDBError(error) {
        var _this = _super.call(this, error.text) || this;
        _this.name = "OpenTDBError [".concat(error.header, "]");
        return _this;
    }
    return OpenTDBError;
}(TypeError));
Elitezen commented 7 months ago

Hey, sorry for the late response, I wasn't notified to this issue's opening. Can you show the code you used to reproduce this error?

Elitezen commented 4 months ago

Issue has been addressed in 2.1.6