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

Fixed log_level arg, added validation error logging #73

Merged
merged 2 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion aries_cloudagent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main():

# Set up logging
log_config = settings.get("log.config")
log_level = settings.get("log_level") or os.getenv("LOG_LEVEL")
log_level = settings.get("log.level") or os.getenv("LOG_LEVEL")
LoggingConfigurator.configure(log_config, log_level)

# Fetch genesis transactions if necessary
Expand Down
7 changes: 6 additions & 1 deletion aries_cloudagent/messaging/models/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Base classes for Models and Schemas."""

import logging
from abc import ABC
import json
from typing import Union
Expand All @@ -9,6 +9,8 @@
from ...classloader import ClassLoader
from ...error import BaseError

LOGGER = logging.getLogger(__name__)


def resolve_class(the_cls, relative_cls: type = None):
"""
Expand Down Expand Up @@ -124,6 +126,7 @@ def deserialize(cls, obj):
try:
return schema.loads(obj) if isinstance(obj, str) else schema.load(obj)
except ValidationError as e:
LOGGER.exception("Message validation error:")
raise BaseModelError("Schema validation failed") from e

def serialize(self, as_string=False) -> dict:
Expand All @@ -141,6 +144,7 @@ def serialize(self, as_string=False) -> dict:
try:
return schema.dumps(self) if as_string else schema.dump(self)
except ValidationError as e:
LOGGER.exception("Message serialization error:")
raise BaseModelError("Schema validation failed") from e

@classmethod
Expand All @@ -158,6 +162,7 @@ def from_json(cls, json_repr: Union[str, bytes]):
try:
parsed = json.loads(json_repr)
except ValueError as e:
LOGGER.exception("Message parse error:")
raise BaseModelError("JSON parsing failed") from e
return cls.deserialize(parsed)

Expand Down