Skip to content

Commit

Permalink
[#1] runtime errors documented
Browse files Browse the repository at this point in the history
  • Loading branch information
shizzard committed Dec 22, 2018
1 parent acd3543 commit 6649c3c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/compile-time-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ You may redefine [private and protected fields](field-types.md) prefixes with se
ERL_COMPILER_OPTIONS='[{d, cloak_priv_prefix="hidden_"}, {d, cloak_prot_prefix, "readonly_"}]'
```
All record fields starting with `hidden_` will be threated as private, and ones starting with `readonly` will be threated as protected.
All record fields starting with `hidden_` will be threated as private, and ones starting with `readonly` will be threated as protected.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* [Exporters](exporters.md): different ways to export data with user-defined callbacks
* [Substructures](substructures.md): explanation of nested data structures `cloak` supports
* [Known issues](known-issues.md)
* [Contributing](contributing.md)
* [Contributing](contributing.md)
13 changes: 13 additions & 0 deletions docs/runtime-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Runtime errors

TL;DR: `cloak` will `throw` the standard `badarg` error in every case other than happy-path one.

It means that you should wrap critical sections of your code with `try..catch` to avoid process crash.

## Validation errors

Validation errors will be generated in case of:

* [Required field](field-types.md) was not found in `Module:new/1` argument map;
* Field value [validation](validators.md) failed with any reason;
* Any of `Module:Getter/1`, `Module:Setter/2`, `Module:update/2`, `Module:export/1` functions being called with wrong type of argument, e.g. invalid value passed instead of `Module` internal record (`Module:t()`).

0 comments on commit 6649c3c

Please sign in to comment.