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

Document some best practices #238

Open
pbiggar opened this issue Apr 26, 2022 · 2 comments
Open

Document some best practices #238

pbiggar opened this issue Apr 26, 2022 · 2 comments

Comments

@pbiggar
Copy link
Member

pbiggar commented Apr 26, 2022

For example, handling inputs/errors at the start of the handler:

match String::toUUID param
| None -> Http::badRequest "param was not a uuid"
| Some id ->
    ... // rest of handler
@sanderjson
Copy link

sanderjson commented Apr 26, 2022

Is there a pattern to avoid "match hell"?

match String::toUUID param_one
| None -> Http::badRequest "param one was not a uuid"
| Some id ->
    ... // rest of handler
    match String::toUUID param_two
    | None -> Http::badRequest "param two was not a uuid"
    | Some id ->
    ... // rest of handler
    ... // etc
match MyCustonTypeSet:: [valA, valB, valC] is [id, string, int]
    | None -> Http::badRequest "Error I"
    | Some -> Http::badRequest "Error II"
    | All -> 
         ... // rest of handler

@pbiggar
Copy link
Member Author

pbiggar commented Apr 26, 2022

Is there a pattern to avoid "match hell"?

When we add tuples there will be, but there isn't right now.

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

No branches or pull requests

2 participants