Throw errors properly

This commit is contained in:
dabbott 2021-02-07 10:44:31 +02:00
parent 36c59d5e69
commit c41900efa9
2 changed files with 5 additions and 5 deletions

View File

@ -7,13 +7,13 @@ gotify = {
priority: 5, priority: 5,
send: (title,message, priority) => { send: (title,message, priority) => {
if (gotify.url == ""){ if (gotify.url == ""){
throw "gotify url value empty, please use: gotify.url == 'https://gotify.mydomain.tld'" throw new Error("gotify url value empty, please use: gotify.url == 'https://gotify.mydomain.tld'")
} else if(gotify.token == "") { } else if(gotify.token == "") {
throw "gotify url value empty, please use: gotify.token == 'xyzxyz'" throw new Error("gotify url value empty, please use: gotify.token == 'xyzxyz'")
} else if(message === undefined) { } else if(message === undefined) {
throw "gotify message value was undefined" throw new Error("gotify message value was undefined")
} else if(title === undefined) { } else if(title === undefined) {
throw "gotify title value was undefined" throw new Error("gotify title value was undefined")
} else { } else {
if (!priority){ if (!priority){
priority = gotify.priority priority = gotify.priority

View File

@ -1,6 +1,6 @@
{ {
"name": "jotify", "name": "jotify",
"version": "1.0.1", "version": "1.0.2",
"description": "A dead simple gotify library for sending arbitrary messages in JS", "description": "A dead simple gotify library for sending arbitrary messages in JS",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {