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
4 changes: 4 additions & 0 deletions .custom-gcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ plugins:
# partitiontest plugin from local source
- module: 'github.com/algorand/go-algorand/cmd/partitiontest_linter'
path: ./cmd/partitiontest_linter
# errortype plugin for error handling consistency
- module: fillmore-labs.com/errortype
import: fillmore-labs.com/errortype/gclplugin
version: v0.0.7
11 changes: 11 additions & 0 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ linters:
enable:
- gosec
- partitiontest
- errortype
settings:
gosec:
excludes: [G101, G103, G104, G107, G112, G114, G115, G202, G204, G301, G302, G303, G304, G306, G307, G404]
custom:
partitiontest:
type: "module"
description: This custom linter ensures test functions call 'partitiontest.PartitionTest(t)'
errortype:
type: module
description: "errortype helps prevent subtle bugs in error handling."
original-url: "https://fillmore-labs.com/errortype"
settings:
style-check: false
deep-is-check: true
check-is: true
unchecked-assert: false
check-unused: true
exclusions:
generated: lax
rules:
Expand Down
13 changes: 12 additions & 1 deletion ledger/ledgercore/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ import (
// ErrNoSpace indicates insufficient space for transaction in block
var ErrNoSpace = errors.New("block does not have space for transaction")

// Verify each custom error type implements the error interface, and declare which are pointer/value receivers.
var (
_ error = (*TxnNotWellFormedError)(nil)
_ error = (*TransactionInLedgerError)(nil)
_ error = (*LeaseInLedgerError)(nil)
_ error = BlockInLedgerError{}
_ error = ErrNoEntry{}
Comment thread
cce marked this conversation as resolved.
_ error = ErrNonSequentialBlockEval{}
_ error = (*TxGroupMalformedError)(nil)
)

// TxnNotWellFormedError indicates a transaction was not well-formed when evaluated by the BlockEvaluator
//
//msgp:ignore TxnNotWellFormedError
Expand All @@ -44,7 +55,7 @@ type TransactionInLedgerError struct {
}

// Error satisfies builtin interface `error`
func (tile TransactionInLedgerError) Error() string {
func (tile *TransactionInLedgerError) Error() string {
return fmt.Sprintf("transaction already in ledger: %v", tile.Txid)
}

Expand Down
2 changes: 1 addition & 1 deletion util/db/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Initialize(accessor Accessor, migrations []Migration) error {
return InitializeWithContext(ctx, tx, migrations)
})

var sqlError *sqlite3.Error
var sqlError sqlite3.Error
if errors.As(err, &sqlError) {
Comment thread
cce marked this conversation as resolved.
return fmt.Errorf("%w. Sql error - Code: %d, Extended Code: %d", err, sqlError.Code, sqlError.ExtendedCode)
}
Expand Down