Skip to content

Commit 57ea0c3

Browse files
committed
Add c8 ignore comments to improve coverage reporting accuracy
1 parent 40b796b commit 57ea0c3

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/http-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ export async function withRetry<T>(
373373
}
374374

375375
// Fallback error if lastError is somehow undefined.
376+
/* c8 ignore next - Defensive fallback for undefined lastError */
376377
throw lastError || new Error('Request failed after retries')
377378
}
378379

src/socket-sdk-class.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export class SocketSdk {
144144
return
145145
}
146146
// Validate response before processing.
147+
/* c8 ignore next 3 - Defensive check, response should always be defined after successful request */
147148
if (!res) {
148149
throw new Error('Failed to get response from batch PURL request')
149150
}
@@ -388,6 +389,7 @@ export class SocketSdk {
388389
return await this.#handleApiError<'batchPackageFetch'>(e)
389390
}
390391
// Validate response before processing.
392+
/* c8 ignore next 3 - Defensive check, response should always be defined after successful request */
391393
if (!res) {
392394
throw new Error('Failed to get response from batch PURL request')
393395
}
@@ -1788,6 +1790,7 @@ export class SocketSdk {
17881790
// Stream to file with error handling.
17891791
const writeStream = createWriteStream(output)
17901792
res.pipe(writeStream)
1793+
/* c8 ignore next 4 - Write stream error handler, difficult to test reliably */
17911794
writeStream.on('error', error => {
17921795
throw new Error(`Failed to write to file: ${output}`, {
17931796
cause: error,
@@ -1796,6 +1799,7 @@ export class SocketSdk {
17961799
} else if (output === true) {
17971800
// Stream to stdout with error handling.
17981801
res.pipe(process.stdout)
1802+
/* c8 ignore next 3 - Stdout error handler, difficult to test reliably */
17991803
process.stdout.on('error', error => {
18001804
throw new Error('Failed to write to stdout', { cause: error })
18011805
})

0 commit comments

Comments
 (0)