Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { fetchBlock } from '../block'
import { mine } from '../test'
import { fetchTransaction } from './fetchTransaction'

import { fetchTransactionReceipt } from './fetchTransactionReceipt'
import {
TransactionReceiptNotFoundError,
fetchTransactionReceipt,
} from './fetchTransactionReceipt'
import { sendTransaction } from './sendTransaction'

test('fetches transaction receipt', async () => {
Expand Down Expand Up @@ -219,3 +222,16 @@ test('throws if transaction not found', async () => {
Version: viem@1.0.2"
`)
})

test('TransactionReceiptNotFoundError', () => {
const error = new TransactionReceiptNotFoundError({
hash: '0xa4b1f606b66105fa45cb5db23d2f6597075701e7f0e2367f4e6a39d17a8cf98a',
})

expect(error.message).toMatchInlineSnapshot(`
"Transaction receipt with hash \\"0xa4b1f606b66105fa45cb5db23d2f6597075701e7f0e2367f4e6a39d17a8cf98a\\" could not be found.

Details: transaction receipt not found
Version: viem@1.0.2"
`)
})
4 changes: 3 additions & 1 deletion packages/core/src/utils/BaseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class BaseError extends Error {
? args.cause.message
: args.details!
const docsPath =
args.cause instanceof BaseError ? args.cause.docsPath : args.docsPath
args.cause instanceof BaseError
? args.cause.docsPath || args.docsPath
: args.docsPath
const message = [
humanMessage,
...(docsPath ? ['', 'Docs: https://viem.sh' + docsPath] : []),
Expand Down
Loading