Skip to content

Commit 60ff6d1

Browse files
committed
style(errors): unify ordering and comments across errors.go
1 parent d81e874 commit 60ff6d1

File tree

10 files changed

+113
-123
lines changed

10 files changed

+113
-123
lines changed

address-codec/errors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ import (
66
)
77

88
var (
9-
// Static errors
9+
// address
1010

1111
// ErrInvalidClassicAddress indicates an invalid classic address.
1212
ErrInvalidClassicAddress = errors.New("invalid classic address")
1313
// ErrInvalidSeed indicates an invalid seed; could not determine encoding algorithm.
1414
ErrInvalidSeed = errors.New("invalid seed; could not determine encoding algorithm")
15-
1615
// ErrInvalidXAddress indicates an invalid x-address.
1716
ErrInvalidXAddress = errors.New("invalid x-address")
1817
// ErrInvalidTag indicates an invalid tag.
1918
ErrInvalidTag = errors.New("invalid tag")
2019
// ErrInvalidAccountID indicates an invalid account ID.
21-
ErrInvalidAccountID = errors.New("invalid accountId")
22-
20+
ErrInvalidAccountID = errors.New("invalid account ID")
2321
// ErrInvalidAddressFormat indicates a general invalid XRPL address format.
2422
ErrInvalidAddressFormat = errors.New("invalid address format")
2523

24+
// checksum
25+
2626
// ErrChecksum indicates that the checksum of a check-encoded string does not verify against
2727
// the checksum.
2828
ErrChecksum = errors.New("checksum error")

binary-codec/definitions/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
var (
9-
// Static errors
9+
// definitions
1010

1111
// ErrUnableToCastFieldInfo is returned when the field info cannot be cast.
1212
ErrUnableToCastFieldInfo = errors.New("unable to cast to field info")

pkg/crypto/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ package crypto
33
import "errors"
44

55
var (
6+
// keypair
7+
68
// ErrValidatorKeypairDerivation is returned when a validator keypair is attempted to be derived
79
ErrValidatorKeypairDerivation = errors.New("validator keypair derivation not supported")
810
// ErrInvalidPrivateKey is returned when a private key is invalid
911
ErrInvalidPrivateKey = errors.New("invalid private key")
1012
// ErrInvalidMessage is returned when a message is required but not provided
1113
ErrInvalidMessage = errors.New("message is required")
12-
1314
// ErrValidatorNotSupported is returned when a validator keypair is used with the ED25519 algorithm.
1415
ErrValidatorNotSupported = errors.New("validator keypairs can not use Ed25519")
1516

1617
// der
1718

1819
// ErrInvalidHexString is returned when the hex string is invalid.
1920
ErrInvalidHexString = errors.New("invalid hex string")
20-
2121
// ErrInvalidDERNotEnoughData is returned when the DER data is not enough.
2222
ErrInvalidDERNotEnoughData = errors.New("invalid DER: not enough data")
2323
// ErrInvalidDERIntegerTag is returned when the DER integer tag is invalid.

xrpl/hash/errors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package hash
33
import "errors"
44

55
var (
6+
// transaction signature
7+
68
// ErrNonSignedTransaction indicates that a transaction lacks the required signature fields.
79
ErrNonSignedTransaction = errors.New("transaction must have at least one of TxnSignature, Signers, or SigningPubKey")
8-
910
// ErrMissingSignature is returned when a transaction lacks the required signature fields.
1011
// A transaction must have at least one of: TxnSignature, Signers, or SigningPubKey,
1112
// unless it's an inner batch transaction (has TfInnerBatchTxn flag set).

xrpl/rpc/errors.go

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,88 +2,83 @@ package rpc
22

33
import "errors"
44

5-
// Static errors
65
var (
6+
// transaction
7+
78
// ErrMissingTxSignatureOrSigningPubKey is returned when a transaction lacks both TxSignature and SigningPubKey.
89
ErrMissingTxSignatureOrSigningPubKey = errors.New("transaction must include either TxSignature or SigningPubKey")
9-
1010
// ErrSignerDataIsEmpty is returned when signer data is empty or missing.
1111
ErrSignerDataIsEmpty = errors.New("signer data must not be empty")
12-
13-
// ErrCannotFundWalletWithoutClassicAddress is returned when attempting to fund a wallet without a classic address.
14-
ErrCannotFundWalletWithoutClassicAddress = errors.New("cannot fund wallet without a classic address")
15-
1612
// ErrMissingLastLedgerSequenceInTransaction is returned when LastLedgerSequence is missing from a transaction.
1713
ErrMissingLastLedgerSequenceInTransaction = errors.New("missing LastLedgerSequence in transaction")
18-
1914
// ErrMissingWallet is returned when a wallet is required but not provided for an unsigned transaction.
2015
ErrMissingWallet = errors.New("wallet must be provided when submitting an unsigned transaction")
16+
// ErrMissingAccountInTransaction is returned when the Account field is missing from a transaction.
17+
ErrMissingAccountInTransaction = errors.New("missing Account in transaction")
18+
// ErrTransactionTypeMissing is returned when the transaction type is missing from a transaction.
19+
ErrTransactionTypeMissing = errors.New("transaction type is missing in transaction")
20+
// ErrTransactionNotFound is returned when a transaction cannot be found.
21+
ErrTransactionNotFound = errors.New("transaction not found")
22+
// ErrInvalidFulfillmentLength is returned when the fulfillment length is invalid.
23+
ErrInvalidFulfillmentLength = errors.New("invalid fulfillment length")
24+
// ErrMismatchedTag is returned when a transaction tag field does not match the expected value.
25+
ErrMismatchedTag = errors.New("transaction tag mismatch")
26+
27+
// fields
2128

2229
// ErrRawTransactionsFieldIsNotAnArray is returned when the RawTransactions field is not an array type.
2330
ErrRawTransactionsFieldIsNotAnArray = errors.New("field RawTransactions must be an array")
24-
2531
// ErrRawTransactionFieldIsNotAnObject is returned when the RawTransaction field is not an object type.
2632
ErrRawTransactionFieldIsNotAnObject = errors.New("field RawTransaction must be an object")
27-
2833
// ErrSigningPubKeyFieldMustBeEmpty is returned when the signingPubKey field should be empty but isn't.
2934
ErrSigningPubKeyFieldMustBeEmpty = errors.New("field SigningPubKey must be empty")
30-
3135
// ErrTxnSignatureFieldMustBeEmpty is returned when the txnSignature field should be empty but isn't.
3236
ErrTxnSignatureFieldMustBeEmpty = errors.New("field TxnSignature must be empty")
33-
3437
// ErrSignersFieldMustBeEmpty is returned when the signers field should be empty but isn't.
3538
ErrSignersFieldMustBeEmpty = errors.New("field Signers must be empty")
36-
3739
// ErrAccountFieldIsNotAString is returned when the account field is not a string type.
3840
ErrAccountFieldIsNotAString = errors.New("field Account must be a string")
41+
// ErrRawTransactionsFieldMissing is returned when the RawTransactions field is missing from a Batch transaction.
42+
ErrRawTransactionsFieldMissing = errors.New("RawTransactions field missing from Batch transaction")
43+
// ErrRawTransactionFieldMissing is returned when the RawTransaction field is missing from a wrapper.
44+
ErrRawTransactionFieldMissing = errors.New("RawTransaction field missing from wrapper")
45+
// ErrFeeFieldMissing is returned when the fee field is missing after calculation.
46+
ErrFeeFieldMissing = errors.New("fee field missing after calculation")
3947

40-
// helpers
48+
// wallet
4149

42-
// ErrMissingAccountInTransaction is returned when the Account field is missing from a transaction.
43-
ErrMissingAccountInTransaction = errors.New("missing Account in transaction")
50+
// ErrCannotFundWalletWithoutClassicAddress is returned when attempting to fund a wallet without a classic address.
51+
ErrCannotFundWalletWithoutClassicAddress = errors.New("cannot fund wallet without a classic address")
52+
53+
// fees
4454

4555
// ErrCouldNotGetBaseFeeXrp is returned when BaseFeeXrp cannot be retrieved from ServerInfo.
46-
ErrCouldNotGetBaseFeeXrp = errors.New("getFeeXrp: could not get BaseFeeXrp from ServerInfo")
56+
ErrCouldNotGetBaseFeeXrp = errors.New("get fee xrp: could not get BaseFeeXrp from ServerInfo")
57+
// ErrCouldNotFetchOwnerReserve is returned when the owner reserve fee cannot be fetched.
58+
ErrCouldNotFetchOwnerReserve = errors.New("could not fetch Owner Reserve")
59+
// ErrFailedToParseFee is returned when fee parsing fails.
60+
ErrFailedToParseFee = errors.New("failed to parse fee")
61+
62+
// account
4763

4864
// ErrAccountCannotBeDeleted is returned when an account cannot be deleted due to associated objects.
4965
ErrAccountCannotBeDeleted = errors.New("account cannot be deleted; there are Escrows, PayChannels, RippleStates, or Checks associated with the account")
5066

67+
// payment
68+
5169
// ErrAmountAndDeliverMaxMustBeIdentical is returned when Amount and DeliverMax fields are not identical.
5270
ErrAmountAndDeliverMaxMustBeIdentical = errors.New("payment transaction: Amount and DeliverMax fields must be identical when both are provided")
5371

54-
// ErrTransactionTypeMissing is returned when the transaction type is missing from a transaction.
55-
ErrTransactionTypeMissing = errors.New("transaction type is missing in transaction")
56-
57-
// ErrTransactionNotFound is returned when a transaction cannot be found.
58-
ErrTransactionNotFound = errors.New("transaction not found")
59-
60-
// ErrCouldNotFetchOwnerReserve is returned when the owner reserve fee cannot be fetched.
61-
ErrCouldNotFetchOwnerReserve = errors.New("could not fetch Owner Reserve")
62-
63-
// ErrRawTransactionsFieldMissing is returned when the RawTransactions field is missing from a Batch transaction.
64-
ErrRawTransactionsFieldMissing = errors.New("RawTransactions field missing from Batch transaction")
65-
66-
// ErrRawTransactionFieldMissing is returned when the RawTransaction field is missing from a wrapper.
67-
ErrRawTransactionFieldMissing = errors.New("RawTransaction field missing from wrapper")
68-
69-
// ErrFeeFieldMissing is returned when the fee field is missing after calculation.
70-
ErrFeeFieldMissing = errors.New("fee field missing after calculation")
71-
72-
// ErrInvalidFulfillmentLength is returned when the fulfillment length is invalid.
73-
ErrInvalidFulfillmentLength = errors.New("invalid fulfillment length")
72+
// tags
7473

7574
// ErrTagMustEqualAddressTag is returned when a tag must equal the address tag.
7675
ErrTagMustEqualAddressTag = errors.New("tag, if present, must be equal to the tag of the address")
7776

77+
// json rpc
78+
7879
// ErrFailedToMarshalJSONRPCRequest is returned when JSON-RPC request marshaling fails.
7980
ErrFailedToMarshalJSONRPCRequest = errors.New("failed to marshal JSON-RPC request")
8081

81-
// ErrFailedToParseFee is returned when fee parsing fails.
82-
ErrFailedToParseFee = errors.New("failed to parse fee")
83-
84-
// ErrMismatchedTag is returned when a transaction tag field does not match the expected value.
85-
ErrMismatchedTag = errors.New("transaction tag mismatch")
86-
8782
// config
8883

8984
// ErrEmptyURL is returned when the provided URL is empty (no port or IP specified).

xrpl/transaction/errors.go

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ var (
4242
// xchain
4343

4444
// ErrInvalidDestinationAddress is returned when the destination address is invalid.
45-
ErrInvalidDestinationAddress = errors.New("xchainClaim: invalid destination address")
45+
ErrInvalidDestinationAddress = errors.New("xchain claim: invalid destination address")
4646
// ErrMissingXChainClaimID is returned when the XChainClaimID is missing.
47-
ErrMissingXChainClaimID = errors.New("xchainClaim: missing XChainClaimID")
47+
ErrMissingXChainClaimID = errors.New("xchain claim: missing XChainClaimID")
4848

4949
// ErrInvalidXChainClaimID is returned when the XChainClaimID is invalid or missing.
5050
ErrInvalidXChainClaimID = errors.New("invalid XChainClaimID")
@@ -132,7 +132,7 @@ var (
132132
// ErrInvalidSignerEntries is returned when the number of signer entries is outside the allowed range.
133133
ErrInvalidSignerEntries = errors.New("invalid number of signer entries")
134134
// ErrInvalidWalletLocator is returned when a SignerEntry's WalletLocator is not a valid hexadecimal string.
135-
ErrInvalidWalletLocator = errors.New("invalid WalletLocator in SignerEntry, must be an hexadecimal string")
135+
ErrInvalidWalletLocator = errors.New("invalid WalletLocator in SignerEntry, must be a hexadecimal string")
136136
// ErrSignerQuorumGreaterThanSumOfSignerWeights is returned when SignerQuorum exceeds sum of all SignerWeights.
137137
ErrSignerQuorumGreaterThanSumOfSignerWeights = errors.New("signerQuorum must be less than or equal to the sum of all SignerWeights")
138138
// ErrInvalidQuorumAndEntries is returned when SignerEntries is non-empty while SignerQuorum is zero.
@@ -193,8 +193,8 @@ var (
193193
// ErrEmptyNFTokenOffers is returned when the NFTokenOffers array contains no entries.
194194
ErrEmptyNFTokenOffers = errors.New("the NFTokenOffers array must have at least one entry")
195195

196-
// ErrInvalidNFTokenID is returned when the NFTokenID is not an hexadecimal.
197-
ErrInvalidNFTokenID = errors.New("invalid NFTokenID, must be an hexadecimal string")
196+
// ErrInvalidNFTokenID is returned when the NFTokenID is not a hexadecimal.
197+
ErrInvalidNFTokenID = errors.New("invalid NFTokenID, must be a hexadecimal string")
198198

199199
// ErrNFTokenBrokerFeeZero is returned when NFTokenBrokerFee is zero.
200200
ErrNFTokenBrokerFeeZero = errors.New("nftoken accept offer: NFTokenBrokerFee cannot be zero")
@@ -296,9 +296,9 @@ var (
296296
// check
297297

298298
// ErrAmountOrDeliverMinNotProvided is returned when neither Amount nor DeliverMin is provided.
299-
ErrAmountOrDeliverMinNotProvided = errors.New("checkCash - either Amount or DeliverMin must be provided")
299+
ErrAmountOrDeliverMinNotProvided = errors.New("check cash: either Amount or DeliverMin must be provided")
300300
// ErrMutuallyExclusiveAmountDeliverMin is returned when both Amount and DeliverMin are provided.
301-
ErrMutuallyExclusiveAmountDeliverMin = errors.New("checkCash - both Amount and DeliverMin cannot be provided")
301+
ErrMutuallyExclusiveAmountDeliverMin = errors.New("check cash: both Amount and DeliverMin cannot be provided")
302302

303303
// batch
304304

@@ -314,26 +314,10 @@ var (
314314
// Each element in the RawTransactions array must be a valid transaction object.
315315
ErrBatchRawTransactionNotObject = errors.New("batch RawTransaction element is not an object")
316316

317-
// ErrBatchRawTransactionMissing is returned when the RawTransaction field is missing from an array element.
318-
// Each RawTransactions array element must contain a RawTransaction field.
319-
ErrBatchRawTransactionMissing = errors.New("batch RawTransaction field is missing")
320-
321317
// ErrBatchRawTransactionFieldNotObject is returned when the RawTransaction field is not an object.
322318
// The RawTransaction field must contain a valid transaction object structure.
323319
ErrBatchRawTransactionFieldNotObject = errors.New("batch RawTransaction field is not an object")
324320

325-
// ErrBatchNestedTransaction is returned when trying to include a Batch transaction within another Batch.
326-
// Nested batch transactions are not allowed to prevent infinite recursion and complexity.
327-
ErrBatchNestedTransaction = errors.New("batch cannot contain nested Batch transactions")
328-
329-
// ErrBatchMissingInnerFlag is returned when an inner transaction lacks the TfInnerBatchTxn flag.
330-
// All transactions within a batch must have the TfInnerBatchTxn flag set to indicate they are inner transactions.
331-
ErrBatchMissingInnerFlag = errors.New("batch RawTransaction must contain the TfInnerBatchTxn flag")
332-
333-
// ErrBatchInnerTransactionInvalid is returned when an inner transaction fails its own validation.
334-
// Each inner transaction must pass its individual validation rules.
335-
ErrBatchInnerTransactionInvalid = errors.New("batch inner transaction validation failed")
336-
337321
// ErrBatchSignerNotObject is returned when a BatchSigner array element is not an object.
338322
// Each element in the BatchSigners array must be a valid signer object.
339323
ErrBatchSignerNotObject = errors.New("batch BatchSigner element is not an object")
@@ -346,10 +330,6 @@ var (
346330
// The BatchSigner field must contain a valid signer object structure.
347331
ErrBatchSignerFieldNotObject = errors.New("batch BatchSigner field is not an object")
348332

349-
// ErrBatchSignerAccountMissing is returned when a BatchSigner lacks the required Account field.
350-
// Each BatchSigner must specify an Account for the signing operation.
351-
ErrBatchSignerAccountMissing = errors.New("batch BatchSigner Account is missing")
352-
353333
// ErrBatchSignerAccountNotString is returned when a BatchSigner Account field is not a string.
354334
// The Account field must be a valid string representing an XRPL account address.
355335
ErrBatchSignerAccountNotString = errors.New("batch BatchSigner Account must be a string")
@@ -393,7 +373,7 @@ var (
393373
// account
394374

395375
// ErrAccountSetInvalidSetFlag is returned when SetFlag is outside the valid range (1 to 16).
396-
ErrAccountSetInvalidSetFlag = errors.New("accountSet: SetFlag must be an integer between asfRequireDest (1) and asfAllowTrustLineClawback (16)")
376+
ErrAccountSetInvalidSetFlag = errors.New("account set: SetFlag must be an integer between asfRequireDest (1) and asfAllowTrustLineClawback (16)")
397377
// ErrAccountSetInvalidTickSize is returned when TickSize is outside the valid range (0 to 15 inclusive).
398-
ErrAccountSetInvalidTickSize = errors.New("accountSet: TickSize must be an integer between 0 and 15 inclusive")
378+
ErrAccountSetInvalidTickSize = errors.New("account set: TickSize must be an integer between 0 and 15 inclusive")
399379
)

xrpl/transaction/types/errors.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,24 @@ var (
66
// xchain bridge
77

88
// ErrInvalidIssuingChainDoorAddress is returned when the issuing chain door address is invalid.
9-
ErrInvalidIssuingChainDoorAddress = errors.New("xchainBridge: invalid issuing chain door address")
9+
ErrInvalidIssuingChainDoorAddress = errors.New("xchain bridge: invalid issuing chain door address")
1010
// ErrInvalidIssuingChainIssueAddress is returned when the issuing chain issue address is invalid.
11-
ErrInvalidIssuingChainIssueAddress = errors.New("xchainBridge: invalid issuing chain issue address")
11+
ErrInvalidIssuingChainIssueAddress = errors.New("xchain bridge: invalid issuing chain issue address")
1212
// ErrInvalidLockingChainDoorAddress is returned when the locking chain door address is invalid.
13-
ErrInvalidLockingChainDoorAddress = errors.New("xchainBridge: invalid locking chain door address")
13+
ErrInvalidLockingChainDoorAddress = errors.New("xchain bridge: invalid locking chain door address")
1414
// ErrInvalidLockingChainIssueAddress is returned when the locking chain issue address is invalid.
15-
ErrInvalidLockingChainIssueAddress = errors.New("xchainBridge: invalid locking chain issue address")
15+
ErrInvalidLockingChainIssueAddress = errors.New("xchain bridge: invalid locking chain issue address")
1616

1717
// raw tx
1818

1919
// ErrBatchRawTransactionMissing is returned when the RawTransaction field is missing from an array element.
2020
ErrBatchRawTransactionMissing = errors.New("batch RawTransaction field is missing")
21-
2221
// ErrBatchRawTransactionFieldNotObject is returned when the RawTransaction field is not an object.
2322
ErrBatchRawTransactionFieldNotObject = errors.New("batch RawTransaction field is not an object")
24-
2523
// ErrBatchNestedTransaction is returned when trying to include a Batch transaction within another Batch.
2624
ErrBatchNestedTransaction = errors.New("batch cannot contain nested Batch transactions")
27-
2825
// ErrBatchMissingInnerFlag is returned when an inner transaction lacks the TfInnerBatchTxn flag.
2926
ErrBatchMissingInnerFlag = errors.New("batch RawTransaction must contain the TfInnerBatchTxn flag")
30-
3127
// ErrBatchInnerTransactionInvalid is returned when an inner transaction fails its own validation.
3228
ErrBatchInnerTransactionInvalid = errors.New("batch inner transaction validation failed")
3329

@@ -40,18 +36,15 @@ var (
4036

4137
// ErrBatchSignerAccountMissing is returned when a BatchSigner lacks the required Account field.
4238
ErrBatchSignerAccountMissing = errors.New("batch BatchSigner Account is missing")
43-
4439
// ErrBatchSignerSigningPubKeyMissing is returned when a BatchSigner lacks the required SigningPubKey field.
4540
ErrBatchSignerSigningPubKeyMissing = errors.New("batch BatchSigner SigningPubKey is missing")
46-
4741
// ErrBatchSignerInvalidTxnSignature is returned when a BatchSigner has an invalid TxnSignature field.
4842
ErrBatchSignerInvalidTxnSignature = errors.New("batch BatchSigner TxnSignature is invalid")
4943

5044
// credential
5145

5246
// ErrInvalidCredentialType is returned when the credential type is invalid; it must be a hexadecimal string between 1 and 64 bytes.
5347
ErrInvalidCredentialType = errors.New("invalid credential type, must be a hexadecimal string between 1 and 64 bytes")
54-
5548
// ErrInvalidCredentialIssuer is returned when the credential Issuer field is missing.
5649
ErrInvalidCredentialIssuer = errors.New("credential type: missing field Issuer")
5750

xrpl/wallet/errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package wallet
33
import "errors"
44

55
var (
6+
// address
7+
68
// ErrAddressTagNotZero is returned when the address tag is not zero.
79
ErrAddressTagNotZero = errors.New("address tag is not zero")
810

0 commit comments

Comments
 (0)