summaryrefslogtreecommitdiff
path: root/jq.pyx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-03-27 13:49:35 +0000
committerMichael Williamson <mike@zwobble.org>2014-03-27 13:49:35 +0000
commit49f5e04a4ceec392c71afdd5e17583cb42c320e6 (patch)
tree547954c0fdd15fb312e90243fef981f5299d3d77 /jq.pyx
parentdb174ba0448a0716daa2e661fafde7d236429b03 (diff)
Encapsulate captured errors a little more cleanly
Diffstat (limited to 'jq.pyx')
-rw-r--r--jq.pyx12
1 files changed, 9 insertions, 3 deletions
diff --git a/jq.pyx b/jq.pyx
index 1174df0..45f3e40 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -61,8 +61,8 @@ def jq(object program):
cdef int compiled = jq_compile(jq, program_bytes)
- if len(error_store._errors) > 0:
- raise ValueError("\n".join(error_store._errors))
+ if error_store.has_errors():
+ raise ValueError(error_store.error_string())
if not compiled:
raise ValueError("program was not valid")
@@ -82,7 +82,13 @@ cdef void store_error(void* store_ptr, jv error):
cdef class _ErrorStore(object):
cdef object _errors
- cdef store_error(self, char* error):
+ cdef int has_errors(self):
+ return len(self._errors)
+
+ cdef object error_string(self):
+ return "\n".join(self._errors)
+
+ cdef void store_error(self, char* error):
self._errors.append(error)