Skip to content

Commit

Permalink
[AAP-11786] Removal of stack trace (#499)
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/AAP-11786

Changed logger.exception to logger.error so we don't print out the stack
trace
  • Loading branch information
mkanoor authored May 3, 2023
2 parents 5c57c8a + 4b68956 commit 554bf7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions ansible_rulebook/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def main(args: List[str] = None) -> int:
asyncio.run(app.run(args))
except KeyboardInterrupt:
return 0
except Exception:
logger.exception("Unexpected exception")
except Exception as err:
logger.error("Terminating %s", str(err))
return 1
return 0

Expand Down
2 changes: 1 addition & 1 deletion ansible_rulebook/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async def start_source(
)
logger.info("Task cancelled " + shutdown_msg)
except BaseException as e:
logger.exception("Source error")
logger.error("Source error %s", str(e))
shutdown_msg = (
f"Shutting down source: {source.source_name} error : {e}"
)
Expand Down
12 changes: 8 additions & 4 deletions ansible_rulebook/rule_set_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,16 @@ async def _call_action(
**action_args,
)
except KeyError as e:
logger.exception(
"KeyError with variables %s", pformat(variables_copy)
logger.error(
"KeyError %s with variables %s",
str(e),
pformat(variables_copy),
)
result = dict(error=e)
except MessageNotHandledException as e:
logger.exception("Message cannot be handled: %s", action_args)
logger.error(
"Message cannot be handled: %s err %s", action_args, str(e)
)
result = dict(error=e)
except MessageObservedException as e:
logger.info("MessageObservedException: %s", action_args)
Expand All @@ -413,7 +417,7 @@ async def _call_action(
logger.debug("Action task caught Cancelled error")
raise
except Exception as e:
logger.exception("Error calling %s", action)
logger.error("Error calling action %s, err %s", action, str(e))
result = dict(error=e)
except BaseException as e:
logger.error(e)
Expand Down
12 changes: 6 additions & 6 deletions ansible_rulebook/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ def _get_schema(cls):
cls.schema = json.loads(data)
validator = jsonschema.validators.validator_for(cls.schema)
validator.check_schema(cls.schema)
except json.JSONDecodeError:
logger.exception("Can not deserialize JSON schema")
except json.JSONDecodeError as err:
logger.error("Can not deserialize JSON schema: %s", str(err))
raise
except SchemaError:
logger.exception("Incorrect JSON schema")
except SchemaError as err:
logger.error("Incorrect JSON schema: %s", str(err))
raise
return cls.schema

@classmethod
def rulebook(cls, instance: List[Dict]) -> None:
try:
jsonschema.validate(instance=instance, schema=cls._get_schema())
except ValidationError:
logger.exception("Rulebook failed validation.")
except ValidationError as err:
logger.error("Rulebook failed validation, err %s", str(err))
raise
4 changes: 2 additions & 2 deletions ansible_rulebook/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ async def send_event_log_to_websocket(
except CancelledError:
logger.info("closing websocket due to task cancelled")
return
except BaseException:
logger.exception("websocket error on %s", event)
except BaseException as err:
logger.error("websocket error on %s err: %s", event, str(err))


def _sslcontext(url, ssl_verify) -> ssl.SSLContext:
Expand Down

0 comments on commit 554bf7a

Please sign in to comment.