diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-03-27 13:49:35 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-03-27 13:49:35 +0000 |
| commit | 49f5e04a4ceec392c71afdd5e17583cb42c320e6 (patch) | |
| tree | 547954c0fdd15fb312e90243fef981f5299d3d77 /jq.pyx | |
| parent | db174ba0448a0716daa2e661fafde7d236429b03 (diff) | |
Encapsulate captured errors a little more cleanly
Diffstat (limited to 'jq.pyx')
| -rw-r--r-- | jq.pyx | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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) |
