post() 에서 발생되는 에러들

import {
	UserDenied, // 사용자 거부 (Deny)
	CreateTxFailed, // TxHash가 만들어지기 이전에 발생된 에러 (Tx 보내지 않았음)
	TxFailed, // TxHash가 만들어진 다음에 발생된 에러 (Tx 보냈는데 에러 발생함)
	Timeout, // Extension 혹은 Walletconnect 에서의 사용자 처리 시간 초과
	TxUnspecifiedError, // 알 수 없는 에러
} from '@terra-money/wallet-provider' // or '@terra-dev/wallet-types'

try {
	const result = await post({} as CreateTxOptions)
} catch (error) {
	if (error instanceof UserDenied) {
		console.log('User Denied')
	} else if (error instanceof CreateTxFailed) {
		console.log('Create Tx Failed')
		console.log(error.message) // 에러 메세지
		console.log(error.tx) // 시도한 CreateTxOptions
	} else if (error instanceof TxFailed) {
		console.log('Tx Failed')
		console.log(error.txhash) // TxHash = string | undefined
		console.log(error.message) // 에러 메세지
		console.log(error.raw_message) // Extension 또는 WalletConnect 를 통해 받은 저수준 에러 정보
		console.log(error.tx) // 시도한 CreateTxOptions
	} else if (error instanceof Timeout) {
		console.log('Timeout')
		console.log(error.message)
	} else if (error instanceof TxUnspecifiedError) {
		console.log('Tx 에서 오류가 발생했지만 뭔지 모르겠음...')
		console.log(error.message) // 에러 메세지
		console.log(error.tx) // 시도한 CreateTxOptions
	} else {
		// catch statement 에는 기본적으로 
		// catch (Error) 가 아니라 catch (unknown) 이 들어오므로
		// Fallback 처리에서는 error.toString() 대신 String(error) 를 사용해야 한다.
		console.log(String(error))
	}
}

Error를 상세하게 분류해서 처리하고자 한다면 위와 같이 instanceof 를 사용해서 Error 의 유형별로 처리할 수 있다. (e.g. Error 종류에 따라 이미지를 다르게 보여줘야 하는 등의 처리가 필요할때)

try {
  const result = await post({} as CreateTxOptions)
} catch (error) {
	console.log(String(error))
}

귀찮으면 그냥 이렇게 해도 된다.