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

fix: use custom errors for the runtime #197

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dignifiedquire
Copy link
Contributor

Fixes #196

This is not ready to be merged, as the exit code mappings are currently screwed up, but opening it for discussion on how this mapping should be implemented if we set things up like this.

cc @anorth @Stebalien

Comment on lines +95 to +121
pub enum Error {
// SysErrIllegalActor
#[error("Method must validate caller identity exactly once")]
CallerAlreadyValidated,
// SysErrForbidden
#[error("caller {0} ist not one of supported")]
UnsupportedCallerAddress(Address),
// SysErrForbidden
#[error("caller cid type {0} not one of supported")]
UnsupportedCallerType(Cid),
#[error("syscall: {0}")]
Syscall(#[from] ErrorNumber),
// ErrIllegalState
#[error("failed to create state; expected empty array CID, got: {0}")]
RootNotEmpty(Cid),
#[error("encoding: {0}")]
CborStore(anyhow::Error),
#[error("no state: {0}")]
NoState(#[from] NoStateError),
#[error("exit code: {0}")]
NonZeroExitCode(ExitCode),
// SysErrIllegalActor
#[error("runtime.send() is not allowed")]
SendNotAllowed,
#[error("actor delete: {0}")]
ActorDelete(#[from] fvm::error::ActorDeleteError),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should define errors for specific syscalls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise the user has to deal with a bunch of non-specific errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand on this a little, do you mean having one error variant per syscall error, or just a general Syscall(SyscallError) variant, or sth else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry. I mean different error types for different runtime functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur

@dignifiedquire
Copy link
Contributor Author

@Stebalien @anorth any other thoughts on how/where to store the mapping of errors to exit codes? Does the way I did it make sense? should it be reusable for the mockvm somehow?

@Stebalien
Copy link
Member

Where there's a clean conversion, I'd implement From<MyRuntimeError> for ActorError, or something like that. But that's also a reason to break the runtime errors up into multiple errors (there won't always be a clean mapping).

@dignifiedquire
Copy link
Contributor Author

Updated: this will be updated once #214 has landed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock runtime should not return ActorError for expectation violations
3 participants