Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/js-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"dependencies": {
"@netlify/open-api": "^2.37.0",
"lodash-es": "^4.17.21",
"micro-api-client": "^3.3.0",
"node-fetch": "^3.0.0",
"p-wait-for": "^5.0.0",
"qs": "^6.9.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/js-client/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import http from 'http'

import test from 'ava'
import fromString from 'from2-string'
import { TextHTTPError, JSONHTTPError } from 'micro-api-client'
import nock from 'nock'
import { v4 as uuidv4 } from 'uuid'

import { NetlifyAPI } from '../lib/index.js'
import { TextHTTPError, JSONHTTPError } from '../lib/methods/response.js'

const scheme = 'http'
const domain = 'localhost'
Expand Down
29 changes: 27 additions & 2 deletions packages/js-client/src/methods/response.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import { JSONHTTPError, TextHTTPError } from 'micro-api-client'

import omit from '../omit.js'

export class HTTPError extends Error {
constructor(response) {
super(response.statusText)
this.name = this.constructor.name
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor)
} else {
this.stack = new Error(response.statusText).stack
}
this.status = response.status
}
}

export class TextHTTPError extends HTTPError {
constructor(response, data) {
super(response)
this.data = data
}
}

export class JSONHTTPError extends HTTPError {
constructor(response, json) {
super(response)
this.json = json
}
}

// Read and parse the HTTP response
export const parseResponse = async function (response) {
const responseType = getResponseType(response)
Expand Down
Loading