@lingo.dev/_sdk 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -87,7 +87,10 @@ var LingoDotDevEngine = class {
87
87
  )
88
88
  });
89
89
  if (!res.ok) {
90
- if (res.status === 400) {
90
+ if (res.status >= 500 && res.status < 600) {
91
+ const errorText = await res.text();
92
+ throw new Error(`Server error (${res.status}): ${res.statusText}. ${errorText}. This may be due to temporary service issues.`);
93
+ } else if (res.status === 400) {
91
94
  throw new Error(`Invalid request: ${res.statusText}`);
92
95
  } else {
93
96
  const errorText = await res.text();
@@ -344,6 +347,9 @@ var LingoDotDevEngine = class {
344
347
  body: JSON.stringify({ text })
345
348
  });
346
349
  if (!response.ok) {
350
+ if (response.status >= 500 && response.status < 600) {
351
+ throw new Error(`Server error (${response.status}): ${response.statusText}. This may be due to temporary service issues.`);
352
+ }
347
353
  throw new Error(`Error recognizing locale: ${response.statusText}`);
348
354
  }
349
355
  const jsonResponse = await response.json();
@@ -368,8 +374,14 @@ var LingoDotDevEngine = class {
368
374
  id: payload.id
369
375
  };
370
376
  }
377
+ if (res.status >= 500 && res.status < 600) {
378
+ throw new Error(`Server error (${res.status}): ${res.statusText}. This may be due to temporary service issues.`);
379
+ }
371
380
  return null;
372
381
  } catch (error) {
382
+ if (error instanceof Error && error.message.includes("Server error")) {
383
+ throw error;
384
+ }
373
385
  return null;
374
386
  }
375
387
  }
package/build/index.mjs CHANGED
@@ -87,7 +87,10 @@ var LingoDotDevEngine = class {
87
87
  )
88
88
  });
89
89
  if (!res.ok) {
90
- if (res.status === 400) {
90
+ if (res.status >= 500 && res.status < 600) {
91
+ const errorText = await res.text();
92
+ throw new Error(`Server error (${res.status}): ${res.statusText}. ${errorText}. This may be due to temporary service issues.`);
93
+ } else if (res.status === 400) {
91
94
  throw new Error(`Invalid request: ${res.statusText}`);
92
95
  } else {
93
96
  const errorText = await res.text();
@@ -344,6 +347,9 @@ var LingoDotDevEngine = class {
344
347
  body: JSON.stringify({ text })
345
348
  });
346
349
  if (!response.ok) {
350
+ if (response.status >= 500 && response.status < 600) {
351
+ throw new Error(`Server error (${response.status}): ${response.statusText}. This may be due to temporary service issues.`);
352
+ }
347
353
  throw new Error(`Error recognizing locale: ${response.statusText}`);
348
354
  }
349
355
  const jsonResponse = await response.json();
@@ -368,8 +374,14 @@ var LingoDotDevEngine = class {
368
374
  id: payload.id
369
375
  };
370
376
  }
377
+ if (res.status >= 500 && res.status < 600) {
378
+ throw new Error(`Server error (${res.status}): ${res.statusText}. This may be due to temporary service issues.`);
379
+ }
371
380
  return null;
372
381
  } catch (error) {
382
+ if (error instanceof Error && error.message.includes("Server error")) {
383
+ throw error;
384
+ }
373
385
  return null;
374
386
  }
375
387
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Lingo.dev JS SDK",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -21,7 +21,7 @@
21
21
  "@paralleldrive/cuid2": "^2.2.2",
22
22
  "jsdom": "^25.0.1",
23
23
  "zod": "^3.24.1",
24
- "@lingo.dev/_spec": "0.34.0"
24
+ "@lingo.dev/_spec": "0.35.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/jsdom": "^21.1.7",