-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve error handling and parser #224
Conversation
ba70dc2
to
37d7cc5
Compare
4e4d3cf
to
0bc42c9
Compare
9d8cc24
to
3791587
Compare
src/request.ts
Outdated
if (options.mode === "parse" || !options.mode) { | ||
data = await responseHandler.getData<T>("parse"); | ||
} | ||
else if (options.mode === "decompress") { | ||
data = await responseHandler.getData("decompress"); | ||
} | ||
else { | ||
data = await responseHandler.getData("raw"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (options.mode === "parse" || !options.mode) { | |
data = await responseHandler.getData<T>("parse"); | |
} | |
else if (options.mode === "decompress") { | |
data = await responseHandler.getData("decompress"); | |
} | |
else { | |
data = await responseHandler.getData("raw"); | |
} | |
if (options.mode === "parse" || !options.mode) { | |
data = await responseHandler.getData<T>("parse"); | |
} | |
else { | |
data = await responseHandler.getData(options.mode); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to update the README to includes new docs like errors no?
test/undiciResponseHandler.spec.ts
Outdated
// Import Third-party Dependencies | ||
import { brotliCompressSync, deflateSync, gzipSync } from "zlib"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zlib is a Node dependency
src/utils.ts
Outdated
@@ -83,6 +47,14 @@ export function createHeaders(options: Partial<Pick<RequestOptions, "headers" | | |||
return headers; | |||
} | |||
|
|||
export function isHttpieError(error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function isHttpieError(error) { | |
export function isHttpieError(error: unknown): error is HttpieError { |
src/utils.ts
Outdated
return error instanceof HttpieError; | ||
} | ||
|
||
export function isHTTPError(error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function isHTTPError(error) { | |
export function isHTTPError(error: unknown): error is HttpieOnHttpError { |
test/HttpieOnHttpError.spec.ts
Outdated
// Import Internal Dependencies | ||
import { HttpieOnHttpError } from "../src/class/HttpieOnHttpError"; | ||
|
||
describe("HttpieOnHttpError", () => { | ||
it("it should create an HttpieOnHttpError with the properties of RequestResponse", () => { | ||
const reqResponse = { | ||
statusCode: 404, | ||
statusMessage: "Not Found", | ||
data: null, | ||
headers: {} | ||
}; | ||
|
||
const error = new HttpieOnHttpError(reqResponse); | ||
expect(error.name).toStrictEqual("HttpieOnHttpError"); | ||
expect(error).toMatchObject(reqResponse); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test do not provide any value (not testing anything).
231d1c1
to
514bbd3
Compare
No description provided.