Skip to content

Polywrap Specific Error Structure #701

@dOrgJelli

Description

@dOrgJelli

Currently, we utilize basic strings for errors, wrapping them within the various languages we have software in (JavaScript & AssemblyScript Error structure, Rust's Err structure, etc).

In the same way that we have standardized structures for the various cross-module operations we support (invoke & subinvoke for example), we should have a standardize error structure that is used.

Information within this structure would include:

  1. Error Message
  2. Source-map Info (file, line, column)
  3. URI
  4. Sub-Errors

Utilizing this information, we can re-create an error-stack, enabling them to further debug where the root cause came from.

Currently we do this through string concatenation & "good faith" that the error propagators in the stack appropriately concatenate to the error string.

Utilizing this method it'd be standard to "push" your error to the stack, and return it to the caller/user of your wrappers/plugins.

Example error stack:

message: "DeFiWrapper: Failed to fetch token data"
source: {file: "./query/index.ts", row: 102, col: 20}
uri: "w3://ens/defiwrapper.eth"
  > message: "UniswapTokenResolver: Unknown pair address"
    source: {file: "./query/pairs/resolver.ts", row: 40, col: 84}
    uri: "w3://ens/uni.resolvers.defiwrapper.eth"
    > message: "Ethereum: Invalid address '0xBAD_ADDRESS'"
      source: {file: "./src/resolver.ts", row: 4343, col: 63}
      uri: "w3://ens/ethereum.wrappers.eth"
..........

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions