koishi-plugin-p-draw 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. package/index.js +17 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1331,7 +1331,23 @@ exports.apply = async function apply(ctx, cfg) {
1331
1331
  body: JSON.stringify(body),
1332
1332
  signal: controller.signal,
1333
1333
  })
1334
- if (!res.ok) throw new Error(`HTTP ${res.status}`)
1334
+ if (!res.ok) {
1335
+ // ComfyUI /prompt 校验失败时会返回 node_errors 等详细错误,尽量带出来便于排查
1336
+ const text = await res.text().catch(() => '')
1337
+ const detail = (() => {
1338
+ try {
1339
+ const data = JSON.parse(text)
1340
+ if (data && data.error) {
1341
+ const extra = data.error.extra_info && data.error.extra_info.node_errors
1342
+ ? Object.entries(data.error.extra_info.node_errors).map(([id, e]) => `${id}:${e.class_type || ''} → ${e.errors ? e.errors.map(x => (x && x.message) || JSON.stringify(x)).join('; ') : JSON.stringify(e)}`).join('\n')
1343
+ : ''
1344
+ return `${data.error.message || ''}${data.error.details ? ' ' + data.error.details : ''}${extra ? '\n' + extra : ''}`.trim()
1345
+ }
1346
+ } catch (e) { /* ignore */ }
1347
+ return text.slice(0, 500)
1348
+ })()
1349
+ throw new Error(`HTTP ${res.status}${detail ? ':' + detail : ''}`)
1350
+ }
1335
1351
  return await res.json()
1336
1352
  } finally {
1337
1353
  clearTimeout(timer)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-p-draw",
3
3
  "description": "p点-绘图,连接本地 ComfyUI 生图。支持自然语言优化、尺寸选择、画师组、固定角色、生成队列,需要配合 p-qiandao 使用",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "index.js",