Skip to content
This repository was archived by the owner on May 29, 2018. It is now read-only.

Commit

Permalink
Merge pull request #5 from mcdermed/dev
Browse files Browse the repository at this point in the history
Better missing param logging
  • Loading branch information
elkwood authored Nov 6, 2017
2 parents 4e48f7e + 5408847 commit 587df34
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@ const routes = require('./factories/routes')
const wares = require('./factories/wares')
const Https = require('./https')

/**
* Politely tell someone they didn't define an arg
* @param {string} name
*/
function argError(name) {
throw new Error(
`You are missing some params! Make sure you set ${name} properly`
)
}

class Sprucebot {
constructor({
apiKey,
skillId,
host,
name,
description,
skillUrl,
svgIcon,
apiKey = argError('apiKey'),
skillId = argError('apiKey'),
host = argError('apiKey'),
name = argError('apiKey'),
description = argError('apiKey'),
skillUrl = argError('apiKey'),
svgIcon = argError('apiKey'),
allowSelfSignedCerts = false
}) {
if (
!apiKey ||
!skillId ||
!host ||
!name ||
!description ||
!skillUrl ||
!svgIcon
) {
throw new Error(
'You are missing some params! Make sure you pass the following: apiKey, skillId, host, name, description, skillUrl & svgIcon.'
)
}

// Setup http(s) class with everything it needs to talk to api
this.name = name
this.description = description
Expand Down

0 comments on commit 587df34

Please sign in to comment.