Skip to content

Commit 3f10252

Browse files
committed
Use Error instead of pony-cause because cause is supported
1 parent be6f6d8 commit 3f10252

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

src/commands/report/create.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import process from 'node:process'
33

44
import { betterAjvErrors } from '@apideck/better-ajv-errors'
55
import meow from 'meow'
6-
import { ErrorWithCause } from 'pony-cause'
76

87
import { SocketValidationError, readSocketConfig } from '@socketsecurity/config'
98
import { Spinner } from '@socketsecurity/registry/lib/spinner'
@@ -188,7 +187,7 @@ async function setupCommand(
188187
.join('\n')
189188
)
190189
} else {
191-
throw new ErrorWithCause('Failed to read socket.yml config', { cause })
190+
throw new Error('Failed to read socket.yml config', { cause })
192191
}
193192
}
194193
)
@@ -206,7 +205,7 @@ async function setupCommand(
206205
return (res as SocketSdkReturnType<'getReportSupportedFiles'>).data
207206
})
208207
.catch((cause: Error) => {
209-
throw new ErrorWithCause('Failed getting supported files for report', {
208+
throw new Error('Failed getting supported files for report', {
210209
cause
211210
})
212211
})

src/commands/report/view.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import process from 'node:process'
22

33
import meow from 'meow'
4-
import { ErrorWithCause } from 'pony-cause'
54
import colors from 'yoctocolors-cjs'
65

76
import { Spinner } from '@socketsecurity/registry/lib/spinner'
@@ -140,8 +139,9 @@ export async function fetchReportData(
140139
} catch (err) {
141140
if (
142141
retry >= MAX_TIMEOUT_RETRY ||
143-
!(err instanceof ErrorWithCause) ||
144-
err.cause?.cause?.response?.statusCode !== 524
142+
!(err instanceof Error) ||
143+
// The 524 HTTP status code indicates a timeout.
144+
(err.cause as any)?.cause?.response?.statusCode !== 524
145145
) {
146146
throw err
147147
}

src/commands/scan/create.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import readline from 'node:readline/promises'
33

44
import meow from 'meow'
55
import open from 'open'
6-
import { ErrorWithCause } from 'pony-cause'
76
import colors from 'yoctocolors-cjs'
87

98
import { Spinner } from '@socketsecurity/registry/lib/spinner'
@@ -159,7 +158,7 @@ async function setupCommand(
159158
.catch(
160159
/** @type {(cause: Error) => never} */
161160
cause => {
162-
throw new ErrorWithCause('Failed getting supported files for report', {
161+
throw new Error('Failed getting supported files for report', {
163162
cause
164163
})
165164
}

src/utils/api.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import process from 'node:process'
22

3-
import { ErrorWithCause } from 'pony-cause'
43
import colors from 'yoctocolors-cjs'
54

65
import { AuthError } from './errors'
@@ -40,13 +39,11 @@ export async function handleApiCall<T>(
4039
description: string
4140
): Promise<T> {
4241
let result: T
43-
4442
try {
4543
result = await value
4644
} catch (cause) {
47-
throw new ErrorWithCause(`Failed ${description}`, { cause })
45+
throw new Error(`Failed ${description}`, { cause })
4846
}
49-
5047
return result
5148
}
5249

0 commit comments

Comments
 (0)