Skip to content

Commit

Permalink
pass thru FIND exception dls-213; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
pothiers committed Apr 4, 2022
1 parent 6fcd320 commit 43d9cc5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sparcl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# must mach: [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
# Example of a correct version string: '0.4.0a3.dev35'
#__version__ = '0.4.0a3.dev36'
__version__ = '0.4.0a4.dev3'
__version__ = '0.4.0a4.dev4'
12 changes: 8 additions & 4 deletions sparcl/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,11 +921,15 @@ def find(self, outfields, constraints=None):
search = [] if constraints is None else constraints
sspec = dict(outfields=outfields, search=search)
res = requests.post(url, json=sspec, timeout=self.timeout)
#!print(f'find res={res.content}')
return Found(res.json(), client=self)
#! info, *rows = res
#! return(rows)

if res.status_code != 200:
#!print(f'DBG: res.content={res.content}') #@@@
if self.verbose and ('traceback' in res.json()):
#!print(f'DBG: res.json={res.json()}')
print(f'DBG: Server traceback=\n{res.json()["traceback"]}')
raise ex.genSparclException(res, verbose=self.verbose)

return Found(res.json(), client=self)
if __name__ == "__main__":
import doctest
doctest.testmod()
6 changes: 6 additions & 0 deletions sparcl/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def genSparclException(response, verbose=False):
return BadPath(status.get('errorMessage'))
elif status.get('errorCode') == 'BADQUERY':
return BadQuery(status.get('errorMessage'))
elif status.get('errorCode') == 'UNKFIELD':
return UnknownField(status.get('errorMessage'))
else:
return UnknownServerError(status.get('errorMessage'))

Expand Down Expand Up @@ -78,4 +80,8 @@ class UnknownSparcl(BaseSparclException):
create and use a new BaseSparcException exception that is more specific."""
error_code = 'UNKSPARC'

class UnknownField(BaseSparclException):
"""Unknown field name for a record"""
error_code = 'UNKFIELD'

# error_code values should be no bigger than 8 characters 12345678

0 comments on commit 43d9cc5

Please sign in to comment.