Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7352d48

Browse files
committedFeb 11, 2025·
Refactor importActorProfile function to improve error handling and remove unused options
1 parent 716ccda commit 7352d48

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎out/test-export-2024-01-01.tar

0 Bytes
Binary file not shown.

‎src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export async function importActorProfile(
192192
onError?: (error: Error, context: { fileName?: string }) => void
193193
} = {}
194194
): Promise<Record<string, any>> {
195-
const { console = undefined, onError = undefined } = options
195+
const { console = undefined } = options
196196
const extract = tar.extract()
197197
const result: Record<string, any> = {}
198198

@@ -239,7 +239,7 @@ export async function importActorProfile(
239239

240240
stream.on('error', (error: any) => {
241241
console?.error(`Stream error on file ${fileName}:`, error.message)
242-
next() // Continue even on stream error
242+
next(error) // Continue even on stream error
243243
})
244244
})
245245

@@ -249,12 +249,12 @@ export async function importActorProfile(
249249
})
250250

251251
extract.on('error', (error) => {
252-
console.error('Error during tar extraction:', error.message)
252+
console?.error('Error during tar extraction:', error.message)
253253
reject(new Error('Failed to extract tar file.'))
254254
})
255255

256256
tarStream.on('error', (error) => {
257-
console.error('Error in tar stream:', error.message)
257+
console?.error('Error in tar stream:', error.message)
258258
reject(new Error('Failed to process tar stream.'))
259259
})
260260

0 commit comments

Comments
 (0)
Please sign in to comment.