Skip to content

Commit c6a6260

Browse files
committed
Make API error more clear
1 parent c8c3199 commit c6a6260

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/utils/alerts-map.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { arrayUnique } from '@socketsecurity/registry/lib/arrays'
22
import { debugDir } from '@socketsecurity/registry/lib/debug'
33
import { logger } from '@socketsecurity/registry/lib/logger'
44
import { getOwn } from '@socketsecurity/registry/lib/objects'
5+
import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
56

67
import { toFilterConfig } from './filter-config.mts'
78
import { extractPurlsFromPnpmLockfile } from './pnpm.mts'
@@ -102,10 +103,13 @@ export async function getAlertsMapFromPurls(
102103
alertsMapOptions,
103104
)
104105
} else if (!opts.nothrow) {
106+
spinner?.stop()
107+
if (isNonEmptyString(batchResult.error)) {
108+
throw new Error(batchResult.error)
109+
}
105110
const statusCode = batchResult.status ?? 'unknown'
106-
const statusMessage = batchResult.error ?? 'No status message'
107111
throw new Error(
108-
`Socket API server error (${statusCode}): ${statusMessage}`,
112+
`Socket API server error (${statusCode}): No status message`,
109113
)
110114
} else {
111115
spinner?.stop()

0 commit comments

Comments
 (0)