go-conflux-sdk icon indicating copy to clipboard operation
go-conflux-sdk copied to clipboard

sdk should provide some common way to check specific error

Open wanliqun opened this issue 3 years ago • 0 comments

As @boqiu metioned in https://github.com/Conflux-Dev/conflux-infura/pull/69#discussion_r655829246, sdk should provide some common way for client application to check if the return error is some specific error.

        epochReceipts, err := cfx.GetEpochReceiptsByPivotBlockHash(pivotHash)
	if err != nil {
		errStr := strings.ToLower(err.Error())

		// pivot hash assumption failed, must be pivot switched
		if strings.Contains(errStr, "pivot assumption failed") || strings.Contains(errStr, "block not found") {
                      // handle pivot switch
                 }
         }

This issue is urgent, and is blocking infura && scan, please take a look and discuss about it.

@Pana @wangdayong228

wanliqun avatar Jun 22 '21 02:06 wanliqun