Fix sdk/undefined response handle error (#1578)

* fix(sdk): update version to 1.25.1 and enhance error handling in FirecrawlApp (#1576)

* package version bump
This commit is contained in:
Rafael Miller 2025-05-20 16:55:07 -03:00 committed by GitHub
parent a5a915d639
commit 6d75161302
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@mendable/firecrawl-js",
"version": "1.25.0",
"version": "1.25.1",
"description": "JavaScript SDK for Firecrawl API",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -560,7 +560,7 @@ export interface GenerateLLMsTextStatusResponse {
export default class FirecrawlApp {
public apiKey: string;
public apiUrl: string;
public version: string = "1.19.1";
public version: string = "1.25.1";
private isCloudService(url: string): boolean {
return url.includes('api.firecrawl.dev');
@ -572,7 +572,7 @@ export default class FirecrawlApp {
return packageJson.default.version;
} catch (error) {
console.error("Error getting version:", error);
return "1.19.1";
return "1.25.1";
}
}
@ -1491,6 +1491,13 @@ export default class FirecrawlApp {
* @param {string} action - The action being performed when the error occurred.
*/
handleError(response: AxiosResponse, action: string): void {
if (!response) {
throw new FirecrawlError(
`No response received while trying to ${action}. This may be a network error or the server is unreachable.`,
0
);
}
if ([400, 402, 403, 408, 409, 500].includes(response.status)) {
const errorMessage: string =
response.data.error || "Unknown error occurred";