Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Improve fail error message #33

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ program

try {
const res = await cancel({ ...command })
json = await res.json()
try {
json = await res.json()
} catch (error) {
throw new Error(`Failed to parse response body as JSON:\n\n${await res.text()}`)
}

if (json.error) {
throw new CancelError(json.error.message)
Expand Down