Commit Graph

4 Commits

Author SHA1 Message Date
Torin Sandall 039c7bdd02 Update error codes and messages throughout
- Refactor error codes to use strings instead of ints.

- Simplify error messages throughout.

- Ensure location set on all expressions. There were a couple locations
  in the parser/compiler where locations were not being set.

- Fallback to rule location in topdown in case location not set. This
  ensures that users get useful locations for API requests with paths
  that refer to virtual docs exactly.

Also add Find function to ast.Value. Useful for extracting values
dynamically. Eventually can support JSON pointers.

Fixes #237
2017-02-16 10:29:57 -08:00
Torin Sandall 725e7e77d1 Tweak error message prefix
Do not display the column number if the filename is set.
2016-11-29 16:08:48 -08:00
Torin Sandall 1a6d7a5a09 Include location attribute on ast errors
Previously, errors returned by the parser and compiler would encode the
location information in the error string. Now, the location information is
structured and can be readily used by consumers.
2016-10-25 09:26:36 -07:00
Torin Sandall 19afe35b84 Fix compiler error reporting
Before, callers would either flatten errors to a string or pick the first
error reported by the compiler. This was a bad approach and lead to an issue
for users running OPA from the command line, for example:

 $ opa run test.rego

If test.rego failed to compile, the run command would only print the first
error...

This change lets callers treat all compiler errors as a single error and
factors the flattening into the Error() implementation of the new ast.Errors
type.
2016-09-29 09:24:32 -07:00