Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect error when invalid language passed. #8

Merged
merged 1 commit into from
Jan 4, 2022
Merged

Fix incorrect error when invalid language passed. #8

merged 1 commit into from
Jan 4, 2022

Conversation

roncli
Copy link
Contributor

@roncli roncli commented Sep 19, 2021

this.resources is not defined at the time this error would be thrown, so we use resources which is defined.

Example code that triggers the incorrect error:

const XIVAPI = require(".");
const xiv = new XIVAPI({"language": "invalid"});

Currently, the error is:

Uncaught TypeError: Cannot read properties of undefined (reading 'languages')
    at new XIVAPI (/mnt/s/dev/git/github/roncli.com/node-roncli-com/node_modules/@xivapi/js/XIVAPI.js:31:74)

After this change, the error becomes:

Uncaught Error: Invalid language given, must be one of: en,ja,de,fr,cn,kr
    at new XIVAPI (/mnt/s/dev/git/github/xivapi-js/XIVAPI.js:31:10)

`this.resources` is not defined at the time this error would be thrown, so we use `resources` which is defined.
@kaimoe kaimoe merged commit 703a057 into xivapi:master Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants