Socket
Socket
Sign inDemoInstall

@octokit/request

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/request - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

3

lib/http-error.js
module.exports = class HttpError extends Error {
constructor (message, code) {
constructor (message, code, headers) {
super(message)

@@ -13,3 +13,4 @@

this.code = code
this.headers = headers
}
}

@@ -55,3 +55,11 @@ 'use strict'

.then(message => {
throw new HttpError(message, status, headers)
const error = new HttpError(message, status, headers)
try {
Object.assign(error, JSON.parse(error.message))
} catch (e) {
// ignore, see octokit/rest.js#684
}
throw error
})

@@ -58,0 +66,0 @@ }

{
"name": "@octokit/request",
"version": "2.0.0",
"version": "2.0.1",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -322,2 +322,36 @@ const chai = require('chai')

})
it('422 error with details', () => {
mockable.fetch = fetchMock.sandbox()
.post('https://api.github.com/repos/octocat/hello-world/labels', {
status: 422,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'X-Foo': 'bar'
},
body: {
message: 'Validation Failed',
errors: [
{
resource: 'Label',
code: 'invalid',
field: 'color'
}
],
documentation_url: 'https://developer.github.com/v3/issues/labels/#create-a-label'
}
})
return octokitRequest('POST /repos/octocat/hello-world/labels', {
name: 'foo',
color: 'invalid'
})
.catch(error => {
expect(error.code).to.equal(422)
expect(error.headers['x-foo']).to.equal('bar')
expect(error.documentation_url).to.equal('https://developer.github.com/v3/issues/labels/#create-a-label')
expect(error.errors).to.deep.equal([{ resource: 'Label', code: 'invalid', field: 'color' }])
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc