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:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mendable/firecrawl-js",
|
"name": "@mendable/firecrawl-js",
|
||||||
"version": "1.25.0",
|
"version": "1.25.1",
|
||||||
"description": "JavaScript SDK for Firecrawl API",
|
"description": "JavaScript SDK for Firecrawl API",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ export interface GenerateLLMsTextStatusResponse {
|
|||||||
export default class FirecrawlApp {
|
export default class FirecrawlApp {
|
||||||
public apiKey: string;
|
public apiKey: string;
|
||||||
public apiUrl: string;
|
public apiUrl: string;
|
||||||
public version: string = "1.19.1";
|
public version: string = "1.25.1";
|
||||||
|
|
||||||
private isCloudService(url: string): boolean {
|
private isCloudService(url: string): boolean {
|
||||||
return url.includes('api.firecrawl.dev');
|
return url.includes('api.firecrawl.dev');
|
||||||
@@ -572,7 +572,7 @@ export default class FirecrawlApp {
|
|||||||
return packageJson.default.version;
|
return packageJson.default.version;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error getting version:", 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.
|
* @param {string} action - The action being performed when the error occurred.
|
||||||
*/
|
*/
|
||||||
handleError(response: AxiosResponse, action: string): void {
|
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)) {
|
if ([400, 402, 403, 408, 409, 500].includes(response.status)) {
|
||||||
const errorMessage: string =
|
const errorMessage: string =
|
||||||
response.data.error || "Unknown error occurred";
|
response.data.error || "Unknown error occurred";
|
||||||
|
|||||||
Reference in New Issue
Block a user