Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vm error strong hierarchy #187

Closed
RicoGit opened this issue Sep 21, 2018 · 1 comment
Closed

Vm error strong hierarchy #187

RicoGit opened this issue Sep 21, 2018 · 1 comment
Assignees
Labels
tech debt ~virtual machine component: virtual machine

Comments

@RicoGit
Copy link
Contributor

RicoGit commented Sep 21, 2018

Motivation

Virtual Machine (VM) produces a lot of different error kinds. Right now VM's methods signatures don't provide a knowledge about produced errors. Each VM method returns a general type of error and there is no way to know, without reading source code, which errors might be produced and which errors will never appear. This is an error-prone and unfriendly API. When new error type will be created a compiler will not make a tip about that and new error might be unhandled.

Proposition

  • Error hierarchy should allow a compiler to make a tip when we forgot to handle some error kind.
  • Method signatures must reflect possible errors. For example, Wasm.apply should produce InitializationError, TrapError, InternalVmError and we need to know this from the signature of the method apply.

Possible solution

Create sealed traits for each method in a VM, for invoke - InvokationError, for getVmState - GetVmStateError and so on. InvokationError sealed trait should become a parent for each error which might be produced in the invoke method. It allows the compiler to detect unhandled errors in pattern-matching through exhaustiveness check.
For example:
sealed trait InternalVmError extends ApplyError with InvokeError with GetVmStateError means that InternalVmError can be produced by methods apply, invoke, getVmState

If there are more suitable solutions with the less boilerplate code we should consider them too.

@RicoGit RicoGit added tech debt ~virtual machine component: virtual machine labels Sep 21, 2018
@RicoGit RicoGit self-assigned this Sep 21, 2018
@xdralex xdralex changed the title Vm error strong hierarhy Vm error strong hierarchy Sep 24, 2018
@alari
Copy link
Member

alari commented Feb 14, 2019

Closed as obsolete

@alari alari closed this as completed Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt ~virtual machine component: virtual machine
Projects
None yet
Development

No branches or pull requests

2 participants