@slopmachine/svelte 0.1.20 → 0.1.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slopmachine/svelte",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "llms": "https://slopmachine-dev.github.io/slopmachine-sdk/llms.txt",
5
5
  "llmsFull": "https://slopmachine-dev.github.io/slopmachine-sdk/llms-full.txt",
6
6
  "description": "The official Svelte SDK for Slop Machine",
@@ -15,7 +15,7 @@
15
15
  />
16
16
  ```
17
17
 
18
- @version 0.1.20
18
+ @version 0.1.22
19
19
  -->
20
20
  <script lang="ts">
21
21
  import {
@@ -108,18 +108,22 @@
108
108
  fetch(src, { method: "HEAD", signal: abortController.signal })
109
109
  .then(async (res) => {
110
110
  if (!res.ok) {
111
- // console.error(`Failed to load image from ${src}. Status: ${res.status} ${res.statusText}`);
111
+ let errorMessage = res.statusText;
112
112
  try {
113
113
  const errRes = await fetch(src, {
114
114
  signal: abortController.signal,
115
115
  });
116
- const errJson = await errRes.json();
117
- console.error("SlopImage error:", res.status, errJson.error);
116
+ const errorText = await errRes.text();
117
+ const errorData = JSON.parse(errorText);
118
+ if (errorData.error) {
119
+ errorMessage = errorData.error;
120
+ }
118
121
  } catch (e: any) {
119
122
  if (e.name !== "AbortError") {
120
123
  // Failed to fetch or parse error details
121
124
  }
122
125
  }
126
+ console.error("SlopImage error:", res.status, errorMessage);
123
127
  isLoading = false;
124
128
  }
125
129
  })
@@ -23,7 +23,7 @@
23
23
  * </SlopText>
24
24
  * ```
25
25
  *
26
- * @version 0.1.20
26
+ * @version 0.1.22
27
27
  */
28
28
  interface Props {
29
29
  // SlopTextOptions
@@ -76,7 +76,17 @@
76
76
 
77
77
  const response = await fetch(url);
78
78
  if (!response.ok) {
79
- throw new Error(`Failed to fetch text: ${response.statusText}`);
79
+ let errorMessage = response.statusText;
80
+ try {
81
+ const errorText = await response.text();
82
+ const errorData = JSON.parse(errorText);
83
+ if (errorData.error) {
84
+ errorMessage = errorData.error;
85
+ }
86
+ } catch (e) {
87
+ // Ignore JSON parse errors if the response isn't JSON
88
+ }
89
+ throw new Error(`Failed to fetch text: ${errorMessage}`);
80
90
  }
81
91
  const content = await response.text();
82
92
  if (isMounted) {
@@ -84,8 +94,10 @@
84
94
  }
85
95
  } catch (err) {
86
96
  if (isMounted) {
87
- error =
97
+ const finalError =
88
98
  err instanceof Error ? err : new Error("Failed to generate text");
99
+ console.error(finalError);
100
+ error = finalError;
89
101
  }
90
102
  } finally {
91
103
  if (isMounted) {
@@ -18,7 +18,7 @@
18
18
  />
19
19
  ```
20
20
 
21
- @version 0.1.20
21
+ @version 0.1.22
22
22
  -->
23
23
  <script lang="ts">
24
24
  import {
@@ -112,17 +112,22 @@
112
112
  fetch(src, { method: "HEAD", signal: abortController.signal })
113
113
  .then(async (res) => {
114
114
  if (!res.ok) {
115
+ let errorMessage = res.statusText;
115
116
  try {
116
117
  const errRes = await fetch(src, {
117
118
  signal: abortController.signal,
118
119
  });
119
- const errJson = await errRes.json();
120
- console.error("SlopVideo error:", res.status, errJson.error);
120
+ const errorText = await errRes.text();
121
+ const errorData = JSON.parse(errorText);
122
+ if (errorData.error) {
123
+ errorMessage = errorData.error;
124
+ }
121
125
  } catch (e: any) {
122
126
  if (e.name !== "AbortError") {
123
127
  // Failed to fetch or parse error details
124
128
  }
125
129
  }
130
+ console.error("SlopVideo error:", res.status, errorMessage);
126
131
  isLoading = false;
127
132
  }
128
133
  })