Skip to content

Commit f0a88f5

Browse files
committed
docs: better linking to errors in docs
1 parent f4b97c0 commit f0a88f5

File tree

2 files changed

+86
-47
lines changed

2 files changed

+86
-47
lines changed

docs.wrm/api/utils/address.wrm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ _property: ethers.utils.getAddress(address) => string<[[address]]> @<utils-getA
4545
Returns //address// as a Checksum Address.
4646

4747
If //address// is an invalid 40-nibble [[HexString]] or if it contains mixed case and
48-
the checksum is invalid, an InvalidArgument Error is thrown.
48+
the checksum is invalid, an [INVALID_ARGUMENT](errors--invalid-argument) Error is thrown.
4949

5050
The value of //address// may be any supported address format.
5151

5252
_property: ethers.utils.getIcapAddress(address) => string<[IcapAddress](address-icap)> @<utils-getIcapAddress> @SRC<address>
5353
Returns //address// as an [ICAP address](link-icap).
54-
Supports the same restrictions as [utils.getAddress](utils-getAddress).
54+
Supports the same restrictions as [getAddress](utils-getAddress).
5555

5656
_property: ethers.utils.isAddress(address) => boolean @<utils-isAddress> @SRC<address>
5757
Returns true if //address// is valid (in any supported format).

docs.wrm/api/utils/logger.wrm

Lines changed: 84 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -48,47 +48,46 @@ Throw an Error with //message// and an optional //code// and
4848
additional //params// set.
4949

5050
_property: logger.throwArgumentError(message, name, value) => never @SRC<logger>
51-
Throw an [INVALID_ARGUMENT](errors-InvalidArgument) Error with //name// and //value//.
52-
51+
Throw an [INVALID_ARGUMENT](errors--invalid-argument) Error with //name// and //value//.
5352

5453
_heading: Usage Validation
5554

5655
There can be used to ensure various properties and actions are safe.
5756

58-
_property: logger.checkAbstract(target, kind) => void @SRC<logger>
59-
Checks that //target// is not //kind// and performs the same operations
60-
as ``checkNew``. This is useful for ensuring abstract classes are not
61-
being instantiated.
57+
_property: logger.checkAbstract(target, kind) => void @<Logger-checkAbstract> @SRC<logger>
58+
If //target// is //kind//, throws a [UNSUPPORTED_OPERATION](errors--unsupported-operation) error
59+
otherwise performs the same operations as [checkNew](Logger-checkNew).
60+
61+
This is useful for ensuring abstract classes are not being instantiated.
6262

63-
_property: logger.checkArgumentCount(count, expectedCount [ , message) => void @SRC<logger>
64-
If //count// is not equal to //expectedCount//, throws a [MISSING_ARGUMENT](errors-MissingArgument)
65-
or [UNEXPECTED_ARGUMENT](errors-UnexpectedArgument) error.
63+
_property: logger.checkArgumentCount(count, expectedCount [ , message) => void @<Logger-checkArgumentCount> @SRC<logger>
64+
If //count// is not equal to //expectedCount//, throws a [MISSING_ARGUMENT](errors--missing-argument)
65+
or [UNEXPECTED_ARGUMENT](errors--unexpected-argument) error.
6666

67-
_property: logger.checkNew(target, kind) => void @SRC<logger>
67+
_property: logger.checkNew(target, kind) => void @<Logger-checkNew> @SRC<logger>
6868
If //target// is not a valid ``this`` or ``target`` value, throw a
69-
[MISSING_NEW](errors-MissingNew) error. This is useful to ensure
69+
[MISSING_NEW](errors--missing-new) error. This is useful to ensure
7070
callers of a Class are using ``new``.
7171

72-
_property: logger.checkNormalize(message) => void @SRC<logger>
72+
_property: logger.checkNormalize(message) => void @<Logger-checkNoralize> @SRC<logger>
7373
Check that the environment has a correctly functioning [[link-js-normalize]]. If not, a
74-
[UNSUPPORTED_OPERATION](errors-UnsupportedOperation) error is thrown.
74+
[UNSUPPORTED_OPERATION](errors--unsupported-operation) error is thrown.
7575

76-
_property: logger.checkSafeUint53(value [, message ]) => void @SRC<logger>
76+
_property: logger.checkSafeUint53(value [, message ]) => void @<Logger-checkSafeUint53> @SRC<logger>
7777
If //value// is not safe as a [JavaScript number](link-wiki-ieee754), throws a
78-
[NUMERIC_FAULT](errors-NumericFault) error.
79-
78+
[NUMERIC_FAULT](errors--numeric-fault) error.
8079

8180
_heading: Censorship @<Logger--censorship>
8281

83-
_property: Logger.setCensorship(censor [ , permanent = false ]) => void @SRC<logger>
82+
_property: Logger.setCensorship(censor [ , permanent = false ]) => void @<Logger-setCensorship> @SRC<logger>
8483
Set error censorship, optionally preventing errors from being uncensored.
8584

8685
In production applications, this prevents any error from leaking information
8786
by masking the message and values of errors.
8887

8988
This can impact debugging, making it substantially more difficult.
9089

91-
_property: Logger.setLogLevel(logLevel) => void @SRC<logger>
90+
_property: Logger.setLogLevel(logLevel) => void @<Logger-setLogLevel> @SRC<logger>
9291
Set the log level, to suppress logging output below a [particular log level](Logger-levels).
9392

9493

@@ -98,86 +97,126 @@ Every error in Ethers has a ``code`` value, which is a string that will
9897
match one of the following error codes.
9998

10099

101-
_heading: Generic Error Codes
100+
_heading: Generic Error Codes @<errors-generic>
102101

103-
_property: Logger.errors.NOT_IMPLEMENTED
104-
The operation is not implemented.
102+
_property: Logger.errors.NOT_IMPLEMENTED @<errors--not-implemented>
103+
The operation is not implemented. This may occur when calling a method
104+
on a sub-class that has not fully implemented its abstract superclass.
105105

106-
_property: Logger.errors.SERVER_ERROR
106+
_property: Logger.errors.SERVER_ERROR @<errors--server-error>
107107
There was an error communicating with a server.
108108

109-
_property: Logger.errors.TIMEOUT @<errors-Timeout>
109+
This may occur for a number of reasons, for example:
110+
111+
- a [CORS](link-cors) issue; this is quite often the problem and also the
112+
hardest to diagnose and fix, so it is very beneficial to familiarize
113+
yourself with CORS; some backends allow you configure your CORS, such as
114+
the geth command-line or conifguration files or the INFURA and Alchemy
115+
dashboards by specifing allowed Origins, methods, etc.
116+
- an SSL issue; for example, if you are trying to connect to a local node via
117+
HTTP but are serving the content from a secure HTTPS website
118+
- a link issue; a firewall is preventing the traffic from reaching the server
119+
- a server issue; the server is down, or is returning 500 error codes
120+
- a backend DDoS mitigation proxy; for example, Etherscan operates behind a
121+
Cloudflare proxy, which will block traffic if the request is sent via
122+
specific User Agents or the client fingerprint is detected as a bot in some
123+
cases
124+
125+
_property: Logger.errors.TIMEOUT @<errors--timeout>
110126
A timeout occurred.
111127

112-
_property: Logger.errors.UNKNOWN_ERROR @<errors-UnknownError>
128+
_property: Logger.errors.UNKNOWN_ERROR @<errors--unknown-error>
113129
A generic unknown error.
114130

115-
_property: Logger.errors.UNSUPPORTED_OPERATION @<errors-UnsupportedOperation>
131+
_property: Logger.errors.UNSUPPORTED_OPERATION @<errors--unsupported-operation>
116132
The operation is not supported.
117133

134+
This can happen for a variety reasons, for example:
135+
136+
- Some backends do not support certain operations; such as passing a blockTag
137+
to an [[EtherscanProvider]] for [call](Provider-call)
138+
- A [[Contract]] object connected to [[Provider]] (instead of a [[Signer]]) cannot
139+
[sign](Signer-signTransaction) or [send](Signer-sendTransaction) transactions
140+
- a [[Contract]] connected to a [[Signer]] without a [[Provider]] is write-only
141+
and cannot estimate gas or execute static calls
118142

119-
_heading: Safety Error Codes
120143

121-
_property: Logger.errors.BUFFER_OVERRUN
144+
_heading: Safety Error Codes @<errors-safety>
145+
146+
_property: Logger.errors.BUFFER_OVERRUN @<errors--buffer-overrun>
122147
The amount of data needed is more than the amount of data required,
123148
which would cause the data buffer to read past its end.
124149

125-
_property: Logger.errors.NUMERIC_FAULT @<errors-NumericFault>
150+
This can occur if a contract erroneously returns invalid ABI-encoded
151+
data or RLP data is malformed.
152+
153+
_property: Logger.errors.NUMERIC_FAULT @<errors--numeric-fault>
126154
There was an invalid operation done on numeric values.
127155

128156
Common cases of this occur when there is [[link-wiki-overflow]],
129157
[[link-wiki-underflow]] in fixed numeric types or division by zero.
130158

131159

132-
_heading: Usage Error Codes
160+
_heading: Usage Error Codes @<errors-usage>
133161

134-
_property: Logger.errors.INVALID_ARGUMENT @<errors-InvalidArgument>
162+
_property: Logger.errors.INVALID_ARGUMENT @<errors--invalid-argument>
135163
The type or value of an argument is invalid. This will generally also
136164
include the ``name`` and ``value`` of the argument. Any function which
137165
accepts sensitive data (such as a private key) will include the string
138-
``[\[REDACTED]\]`` instead of the value passed in.
166+
``"[\[REDACTED]\]"`` instead of the value passed in.
139167

140-
_property: Logger.errors.MISSING_ARGUMENT @<errors-MissingArgument>
168+
_property: Logger.errors.MISSING_ARGUMENT @<errors--missing-argument>
141169
An expected parameter was not specified.
142170

143-
_property: Logger.errors.MISSING_NEW @<errors-MissingNew>
144-
An object is a Class, but is now being called with ``new``.
171+
_property: Logger.errors.MISSING_NEW @<errors--missing-new>
172+
An object is a Class, but is not being called with ``new``.
145173

146-
_property: Logger.errors.UNEXPECTED_ARGUMENT @<errors-UnexpectedArgument>
174+
_property: Logger.errors.UNEXPECTED_ARGUMENT @<errors--unexpected-argument>
147175
Too many parameters we passed into a function.
148176

149177

150-
_heading: Ethereum Error Codes
178+
_heading: Ethereum Error Codes @<errors-ethereum>
151179

152-
_property: Logger.errors.CALL_EXCEPTION
180+
_property: Logger.errors.CALL_EXCEPTION @<errors--call-exception>
153181
An attempt to call a blockchain contract (getter) resulted in a
154-
revert or other error.
182+
revert or other error, such as insufficient gas (out-of-gas) or an
183+
invalid opcode. This can also occur during gas estimation or if
184+
waiting for a [[providers-TransactionReceipt]] which failed during execution.
185+
186+
Consult the contract to determine the cause, such as a failed condition
187+
in a ``require`` statement. The ``reason`` property may provide more
188+
context for the cause of this error.
155189

156-
_property: Logger.errors.INSUFFICIENT_FUNDS
190+
_property: Logger.errors.INSUFFICIENT_FUNDS @<errors--insufficient-funds>
157191
The account is attempting to make a transaction which costs more than is
158192
available.
159193

160194
A sending account must have enough ether to pay for the value, the gas limit
161195
(at the gas price) as well as the intrinsic cost of data. The intrinsic cost
162-
of data is 4 gas for each zero byte and 68 gas for each non-zero byte.
196+
of data is 4 gas for each zero byte and 68 gas for each non-zero byte, as well
197+
as 35000 gas if a transaction contains no ``to`` property and is therefore
198+
expected to create a new account.
163199

164-
_property: Logger.errors.NETWORK_ERROR
200+
_property: Logger.errors.NETWORK_ERROR @<errors--network>
165201
An Ethereum network validation error, such as an invalid chain ID.
166202

167-
_property: Logger.errors.NONCE_EXPIRED
203+
_property: Logger.errors.NONCE_EXPIRED @<errors--nonce-expired>
168204
The nonce being specified has already been used in a mined transaction.
169205

170-
_property: Logger.errors.REPLACEMENT_UNDERPRICED
206+
_property: Logger.errors.REPLACEMENT_UNDERPRICED @<errors--replacement-underpriced>
171207
When replacing a transaction, by using a nonce which has already been sent to
172208
the network, but which has not been mined yet the new transaction must specify
173209
a higher gas price.
174210

175211
This error occurs when the gas price is insufficient to //bribe// the transaction
176212
pool to prefer the new transaction over the old one. Generally, the new gas price
177213
should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the
178-
replacement should be 15.000000001 gwei.
214+
replacement should be 15.000000001 gwei. This is not enforced by the protocol, as
215+
it deals with unmined transactions, and can be configured by each node, however
216+
to ensure a transaction is propagated to a miner it is best practice to follow
217+
the defaults most nodes have enabled.
179218

180-
_property: Logger.errors.UNPREDICTABLE_GAS_LIMIT
219+
_property: Logger.errors.UNPREDICTABLE_GAS_LIMIT @<errors--unpredicatable-gas-limit>
181220
When estimating the required amount of gas for a transaction, a node is queried for
182221
its best guess.
183222

0 commit comments

Comments
 (0)