Skip to content
Draft
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions packages/cli-kit/src/public/node/error-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ describe('errorHandler', async () => {
expect(outputMock.info()).toMatch('✨ Custom message')
expect(process.exit).toBeCalledTimes(0)
})

test('finishes the execution without exiting the proccess when AbortSilentError is raised', async () => {
// Given
vi.spyOn(process, 'exit').mockResolvedValue(null as never)
const outputMock = mockAndCaptureOutput()
outputMock.clear()

// When
await errorHandler(new error.AbortSilentError())

// Then
expect(outputMock.info()).toBe('')
expect(process.exit).toBeCalledTimes(0)
})
})

describe('bugsnag stack cleaning', () => {
Expand Down
19 changes: 9 additions & 10 deletions packages/cli-kit/src/public/node/error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ export async function errorHandler(
if (error.message && error.message !== '') {
outputInfo(`✨ ${error.message}`)
}
} else if (error instanceof AbortSilentError) {
/* empty */
} else {
return errorMapper(error)
.then((error) => {
return handler(error)
})
.then((mappedError) => {
return reportError(mappedError, config)
})
return
}

if (error instanceof AbortSilentError) {
return
}

const mappedError = await errorMapper(error)
await handler(mappedError)
await reportError(mappedError, config)
}

const reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {
Expand Down
Loading