Skip to content

Commit b109bdf

Browse files
committed
fix: datasets: handle error responses
Signed-off-by: Grant Linville <[email protected]>
1 parent 96d3724 commit b109bdf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/gptscript.ts

+15
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ export class GPTScript {
401401
const r: Run = new RunSubcommand("datasets", "", {URL: this.opts.URL, Token: this.opts.Token})
402402
r.request({input: "{}", workspace: workspace, datasetToolRepo: this.opts.DatasetToolRepo ?? ""})
403403
const result = await r.text()
404+
if (result.startsWith("ERROR:")) {
405+
throw new Error(result)
406+
}
404407
return JSON.parse(result) as Array<DatasetMeta>
405408
}
406409

@@ -416,6 +419,9 @@ export class GPTScript {
416419
datasetToolRepo: this.opts.DatasetToolRepo ?? ""
417420
})
418421
const result = await r.text()
422+
if (result.startsWith("ERROR:")) {
423+
throw new Error(result)
424+
}
419425
return JSON.parse(result) as Dataset
420426
}
421427

@@ -436,6 +442,9 @@ export class GPTScript {
436442
datasetToolRepo: this.opts.DatasetToolRepo ?? ""
437443
})
438444
const result = await r.text()
445+
if (result.startsWith("ERROR:")) {
446+
throw new Error(result)
447+
}
439448
return JSON.parse(result) as DatasetElementMeta
440449
}
441450

@@ -451,6 +460,9 @@ export class GPTScript {
451460
datasetToolRepo: this.opts.DatasetToolRepo ?? ""
452461
})
453462
const result = await r.text()
463+
if (result.startsWith("ERROR:")) {
464+
throw new Error(result)
465+
}
454466
return JSON.parse(result) as Array<DatasetElementMeta>
455467
}
456468

@@ -466,6 +478,9 @@ export class GPTScript {
466478
datasetToolRepo: this.opts.DatasetToolRepo ?? ""
467479
})
468480
const result = await r.text()
481+
if (result.startsWith("ERROR:")) {
482+
throw new Error(result)
483+
}
469484
return JSON.parse(result) as DatasetElement
470485
}
471486

0 commit comments

Comments
 (0)