Skip to content

Commit

Permalink
try catch?
Browse files Browse the repository at this point in the history
  • Loading branch information
w-vi committed Nov 27, 2015
1 parent 66bcd2f commit 7ab8829
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/reporters/apiary-reporter.coffee
Expand Up @@ -242,9 +242,6 @@ class ApiaryReporter
'User-Agent': "Dredd REST Reporter/" + packageConfig['version'] + " (" + system + ")"
'Content-Type': 'application/json'
'Content-Length': Buffer.byteLength(postData, 'utf8')
rejectUnauthorized: false

options.agent = new https.Agent(options)

unless @configuration['apiToken'] == null
options.headers['Authentication'] = 'Token ' + @configuration['apiToken']
Expand All @@ -259,7 +256,6 @@ class ApiaryReporter
handleReqError = (error) =>
@serverError = true
console.log 'error handled'
console.log CONNECTION_ERRORS.indexOf(error.code)
if CONNECTION_ERRORS.indexOf(error.code) > -1
return callback "Apiary reporter: Error connecting to Apiary test reporting API."
else
Expand All @@ -270,18 +266,16 @@ class ApiaryReporter

if @configuration.apiUrl?.indexOf('https') is 0
console.log 'https'
# options.rejectUnauthorized = false
# options.agent = new https.Agent( options )
console.log options
req = https.request options, handleResponse
else
console.log 'http'
console.log options
req = http.request options, handleResponse

req.on 'error', handleReqError
console.log req._events["error"].toString()
req.write postData
req.end()
try
req.on 'error', handleReqError
req.write postData
req.end()
catch e
handleReqError e

module.exports = ApiaryReporter

0 comments on commit 7ab8829

Please sign in to comment.