Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

improve types in jesse.erl #10

Closed
Cy6erBr4in opened this issue Oct 7, 2013 · 1 comment
Closed

improve types in jesse.erl #10

Cy6erBr4in opened this issue Oct 7, 2013 · 1 comment

Comments

@Cy6erBr4in
Copy link
Contributor

 andreineculau 2 days ago 
I personally would have liked 1) the error to be more uniform 2) the errors to be categorized e.g.

-type error_reason() :: { 'schema_invalid'
                        , Schema :: json_term()
                        , Error :: schema_error()
                        }
                      | { 'data_invalid'
                        , Schema :: json_term()
                        , Error  :: data_error()
                        , Data   :: json_term()
                        }.

-type schema_error() :: {schema_error_id(), Details :: any() }
-type schema_error_id() :: 'missing_id_field'
                         | ...

-type data_error() :: {data_error_id(), Details :: any() }
-type data_error_id() :: 'missing_required_property'
                       | ...
Reason: improved/clearer documentation IMO, and cleaner pattern matching.

Just a thought, @Cy6erBr4in :) Nice effort

PS: the above is just to illustrate the pattern; the type definition (for Details) can be more explicit per *errorid and more documentation-driven
@richcarl
Copy link
Contributor

Closing. See for-GET/jesse#6

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

No branches or pull requests

2 participants