Skip to content

Custom error message not working #2957

@KieranP

Description

@KieranP

Bug description

Using either:

class LocationOccupied extends Error {
  constructor(message: string) {
    super(`LocationOccupied(${message})`);
  }
}

OR

class LocationOccupied extends Error {
  constructor(message: string) {
    this.message = `LocationOccupied(${message})`;
  }
}

OR

class LocationOccupied extends Error {
  toString(): string {
    return `LocationOccupied(${this.message})`
  }
}

and calling this:

throw new LocationOccupied(`${x}-${y}`)

I'm not getting a custom message:

› wasmer run build/release.wasm
⠁ Compiling to WebAssembly                                                                                                                                                                                                                                  abort: 0-0 in assembly/world.ts(107:7)

› wasmtime run build/release.wasm
abort: 0-0 in assembly/world.ts(107:7)
Error: failed to run main module `build/release.wasm`

Notice only "0-0" is getting output, which is what is passed into the throw.

The change of the message in the custom error class doesn't apply.

Steps to reproduce

See above

AssemblyScript version

v0.28.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions