Skip to content

Results, Exceptions, and Custom Effects #452

Answered by TimWhiting
MrJohz asked this question in Q&A
Discussion options

You must be logged in to vote

For domains specific exceptions it is often appropriate to create your own exception effect which allows you to ensure that you are catching only your kind of exception where you want to handle it, and not any other types of exceptions, as well as any other domain-specific exit behaviors.

However, that being said, you'll notice that throw takes an optional argument exception-info, of which there are a few variants (and you'll notice it is an open type).

// The exception data type
pub value struct exception( message :string, info :exception-info )

// Exception information
pub open type exception-info
  ExnError      // Generic error
  ExnAssert
  ExnTodo
  ExnRange
  ExnPattern( location …

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@TimWhiting
Comment options

@TimWhiting
Comment options

@chtenb
Comment options

@MrJohz
Comment options

@TimWhiting
Comment options

Answer selected by MrJohz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants