Skip to content

Commit 6c6a6f9

Browse files
committed
fix: throw correct message from discord
1 parent bbd9786 commit 6c6a6f9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "midjourney-fetch",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "",
55
"type": "module",
66
"main": "./dist/index.js",

src/midjourney.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,17 @@ export class Midjourney {
9696
},
9797
});
9898
if (res.status >= 400) {
99+
let message = '';
99100
try {
100101
const data = await res.json();
101102
if (this.debugger) {
102103
this.log('Interactions failed', JSON.stringify(data));
103104
}
104-
if (data?.message) {
105-
throw new Error(data.message);
106-
}
105+
message = data?.message;
107106
} catch (e) {
108107
// catch JSON error
109108
}
110-
throw new Error(`Interactions failed with ${res.status}`);
109+
throw new Error(message || `Interactions failed with ${res.status}`);
111110
}
112111
}
113112

0 commit comments

Comments
 (0)