Skip to content

Commit

Permalink
🥅 custom error if no time given in getHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
loloToster committed Jan 22, 2022
1 parent 5c35388 commit 1cbee93
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ class OpenWeatherAPI {
* }>}
*/
async getHistory(dt, options = {}) {
if (dt === undefined) throw new Error("Provide time")
await this.#uncacheLocation(options.key)
dt = Math.round(new Date(dt).getTime() / 1000)
options = await this.#parseOptions(options)
Expand Down
2 changes: 1 addition & 1 deletion test/errors_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe("Error tests:", function () {
try {
await weather.getHistory()
} catch (err) {
assert(err.message.toLowerCase().includes("no location or time specified"))
assert(err.message.toLowerCase().includes("provide time"))
return
}
assert(false)
Expand Down

0 comments on commit 1cbee93

Please sign in to comment.