Skip to content
Open
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
16 changes: 16 additions & 0 deletions __tests__/utils/configBlunderbussDelay.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe, expect, it, vi } from 'vitest'

import { parseProwConfig } from '../../src/utils/config'
import * as duration from '../../src/utils/duration'

vi.mock('../../src/utils/duration', { spy: true })

describe('normalizeBlunderbuss', () => {
it('stringifies a non-Error thrown while parsing blunderbuss.delay', () => {
vi.mocked(duration.parseDuration).mockImplementationOnce(() => {
throw 'clock skew' // eslint-disable-line no-throw-literal
})

expect(() => parseProwConfig('x', 'blunderbuss:\n delay: 1h\n')).toThrow('x: clock skew')
})
})
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41210,7 +41210,8 @@ function normalizeBlunderbuss(source, raw) {
ms = parseDuration(raw.delay, 'blunderbuss.delay');
}
catch (e) {
throw new Error(`${source}: ${e instanceof Error ? e.message : e}`);
// parseDuration throws only Error
throw new Error(`${source}: ${e instanceof Error ? e.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; configBlunderbussDelay.test.ts drives it */ e}`);
}
if (ms > maxBlunderbussDelayMs) {
throw new Error(`${source}: blunderbuss.delay must not be longer than 24h`);
Expand Down
3 changes: 2 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ function normalizeBlunderbuss(source: string, raw: unknown): BlunderbussConfig {
ms = parseDuration(raw.delay, 'blunderbuss.delay')
}
catch (e) {
throw new Error(`${source}: ${e instanceof Error ? e.message : e}`)
// parseDuration throws only Error
throw new Error(`${source}: ${e instanceof Error ? e.message : /* v8 ignore next -- non-Error arm unreachable from dist/index.js; configBlunderbussDelay.test.ts drives it */ e}`)
}
if (ms > maxBlunderbussDelayMs) {
throw new Error(`${source}: blunderbuss.delay must not be longer than 24h`)
Expand Down
Loading