These are just a few simple logging utilities provided to simplify and standardize the error facilities across the Hethers library.
The Logger library has zero dependencies and is intentionally very light so it can be easily included in each library.
The Censorship functionality relies on one instance of the Hethers library being included. In large bundled packages or when
npm linkis used, this may not be the case. If you require this functionality, ensure that your bundling is configured properly.
Create a new logger which will include version in all errors thrown.
Returns the singleton global logger.
Log debugging information.
Log generic information.
These functions honor the current Censorship and help create a standard error model for detecting and processing errors within Hethers.
Create an Error object with message and an optional code and additional params set. This is useful when an error is needed to be rejected instead of thrown.
Throw an Error with message and an optional code and additional params set.
There can be used to ensure various properties and actions are safe.
If target is kind, throws a UNSUPPORTED_OPERATION error otherwise performs the same operations as checkNew.
This is useful for ensuring abstract classes are not being instantiated.
If target is not a valid
targetvalue, throw a MISSING_NEW error. This is useful to ensure callers of a Class are using
Check that the environment has a correctly functioning String.normalize. If not, a UNSUPPORTED_OPERATION error is thrown.
Set error censorship, optionally preventing errors from being uncensored.
In production applications, this prevents any error from leaking information by masking the message and values of errors.
This can impact debugging, making it substantially more difficult.
Every error in Hethers has a
codevalue, which is a string that will match one of the following error codes.
The operation is not implemented. This may occur when calling a method on a sub-class that has not fully implemented its abstract superclass.
There was an error communicating with a server.
This may occur for a number of reasons, for example:
- a CORS issue; this is quite often the problem and also the hardest to diagnose and fix, so it is very beneficial to familiarize yourself with CORS; some backends allow you configure your CORS, such as the geth command-line or conifguration files or the INFURA and Alchemy dashboards by specifing allowed Origins, methods, etc.
- an SSL issue; for example, if you are trying to connect to a local node via HTTP but are serving the content from a secure HTTPS website
- a link issue; a firewall is preventing the traffic from reaching the server
- a server issue; the server is down, or is returning 500 error codes
- a backend DDoS mitigation proxy; for example a Cloudflare proxy, which will block traffic if the request is sent via specific User Agents or the client fingerprint is detected as a bot in some cases
A timeout occurred.
A generic unknown error.
The operation is not supported.
This can happen for a variety reasons, for example:
The amount of data needed is more than the amount of data required, which would cause the data buffer to read past its end.
This can occur if a contract erroneously returns invalid ABI-encoded data or RLP data is malformed.
There was an invalid operation done on numeric values.
Common cases of this occur when there is overflow, arithmetic underflow in fixed numeric types or division by zero.
The type or value of an argument is invalid. This will generally also include the
valueof the argument. Any function which accepts sensitive data (such as a private key) will include the string
"[[REDACTED]]"instead of the value passed in.
An expected parameter was not specified.
An object is a Class, but is not being called with
Too many parameters we passed into a function.
An attempt to call a contract (getter) resulted in a revert or other error, such as insufficient gas (out-of-gas) or an invalid opcode. This can also occur during gas estimation or if waiting for a TransactionReceipt which failed during execution.
Consult the contract to determine the cause, such as a failed condition in a
reasonproperty may provide more context for the cause of this error.
The account is attempting to make a transaction which costs more than is available.
A sending account must have enough hbar to pay for the value, the gas limit (at the gas price) as well as the intrinsic cost of data.
A Hedera network validation error, such as an invalid chain ID.
When estimating the required amount of gas for a transaction, a node is queried for its best guess.
If a node is unable (or unwilling) to predict the cost, this error occurs.
The best remedy for this situation is to specify a gas limit in the transaction manually.
This error can also indicate that the transaction is expected to fail regardless, if for example an account with no tokens is attempting to send a token.
Log all output, including debugging information.
Only log output for informational, warnings and errors.
Only log output for warnings and errors.
Only log output for errors.
Do not output any logs.