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

Error handling #13

Open
MatheusRich opened this issue Jun 6, 2021 · 0 comments
Open

Error handling #13

MatheusRich opened this issue Jun 6, 2021 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@MatheusRich
Copy link
Collaborator

MatheusRich commented Jun 6, 2021

V's error handling seems to be a good fit here.

This would play nicely with the idea of "soft-typing" (i.e. world's laziest type checker):

User = {
  db = [{id: 1, name "Matz"}, {id: 2, name "Matheus"}]

  # The ! here means it may fail
  find! = fn { |id|
    List.each(db, fn { |user|
      if user.id == id { return user; }
    });

    return none; # or return error("msg")
  }
}

User.find!(3) or { {id: 0, name "Dummy user"} }
@MatheusRich MatheusRich added the enhancement New feature or request label Jun 6, 2021
@MatheusRich MatheusRich added this to the Lit-next milestone Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant