Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE]: tmp: annotate exceptions #94

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyodata/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ def _fetch_metadata(connection, url, logger):
resp.content)

if resp.status_code != 200:
# ANNOT_EX: fatal runtime communication initialization error on service side
raise HttpError(
'Metadata request failed, status code: {}, body:\n{}'.format(resp.status_code, resp.content), resp)

mime_type = resp.headers['content-type']
if not any((typ in ['application/xml', 'text/xml'] for typ in mime_type.split(';'))):
# ANNOT_EX: fatal runtime communication initialization error on service side
raise HttpError(
'Metadata request did not return XML, MIME type: {}, body:\n{}'.format(mime_type, resp.content),
resp)
Expand Down Expand Up @@ -54,6 +56,7 @@ def __new__(cls, url, connection, odata_version=ODATA_VERSION_2, namespaces=None
logger.info('Using static metadata')

if config is not None and namespaces is not None:
# ANNOT_EX: fatal invalid usage error
raise PyODataException('You cannot pass namespaces and config at the same time')

if config is None:
Expand All @@ -73,4 +76,5 @@ def __new__(cls, url, connection, odata_version=ODATA_VERSION_2, namespaces=None

return service

# ANNOT_EX: fatal runtime initialization error on pyodata side
raise PyODataException('No implementation for selected odata version {}'.format(odata_version))
17 changes: 17 additions & 0 deletions pyodata/exceptions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
internal error:
- unimplemented handlers
- unimplemented if/else branch
- type mismatch when resolving odata metadata references (

service error:
- invalid metadata
-- unknown reference target (ValueHelper annotation, Assocition role, ...)
-- redefinition of something
-- malformed metadata (e.g. missing Navigation role XML nodes)
- runtime
-- malformed http responses
-- malformed odata values

programmer error:
- request unknown type / property
- assigns invalid data
Loading