@chirpie/sdk 1.0.8 → 1.0.9

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/dist/index.js CHANGED
@@ -65,12 +65,24 @@ var ChirpieClient = class {
65
65
  Authorization: `Bearer ${this.apiKey}`,
66
66
  "Content-Type": "application/json"
67
67
  };
68
- const res = await fetch(url, {
69
- method,
70
- headers,
71
- body: body ? JSON.stringify(body) : void 0
72
- });
73
- const json = await res.json();
68
+ let res;
69
+ try {
70
+ res = await fetch(url, {
71
+ method,
72
+ headers,
73
+ body: body ? JSON.stringify(body) : void 0
74
+ });
75
+ } catch (err) {
76
+ throw new ChirpieError(
77
+ err instanceof Error ? `Network error: ${err.message}` : "Network error"
78
+ );
79
+ }
80
+ let json;
81
+ try {
82
+ json = await res.json();
83
+ } catch {
84
+ throw new ChirpieApiError("parse_error", "Invalid response from server", res.status);
85
+ }
74
86
  if (!res.ok) {
75
87
  const err = json.error ?? { code: "unknown", message: "Request failed" };
76
88
  throw new ChirpieApiError(err.code, err.message, res.status);
package/dist/index.mjs CHANGED
@@ -33,12 +33,24 @@ var ChirpieClient = class {
33
33
  Authorization: `Bearer ${this.apiKey}`,
34
34
  "Content-Type": "application/json"
35
35
  };
36
- const res = await fetch(url, {
37
- method,
38
- headers,
39
- body: body ? JSON.stringify(body) : void 0
40
- });
41
- const json = await res.json();
36
+ let res;
37
+ try {
38
+ res = await fetch(url, {
39
+ method,
40
+ headers,
41
+ body: body ? JSON.stringify(body) : void 0
42
+ });
43
+ } catch (err) {
44
+ throw new ChirpieError(
45
+ err instanceof Error ? `Network error: ${err.message}` : "Network error"
46
+ );
47
+ }
48
+ let json;
49
+ try {
50
+ json = await res.json();
51
+ } catch {
52
+ throw new ChirpieApiError("parse_error", "Invalid response from server", res.status);
53
+ }
42
54
  if (!res.ok) {
43
55
  const err = json.error ?? { code: "unknown", message: "Request failed" };
44
56
  throw new ChirpieApiError(err.code, err.message, res.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chirpie/sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Chirpie SDK — TypeScript client for the Chirpie social media API",
5
5
  "repository": {
6
6
  "type": "git",