Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Added from e to add the exception to the traceback to better log the …
Browse files Browse the repository at this point in the history
…exceptions
  • Loading branch information
Nicolas-Klatzer committed Apr 9, 2021
1 parent 7ad0f56 commit 4271f2f
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions openhivenpy/types/attatchment.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ async def from_dict(cls, data: dict, http, **kwargs):

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ async def from_dict(cls, data: dict, http, **kwargs):

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ async def from_dict(cls, data: dict, http, **kwargs):

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ async def from_dict(cls, data: dict, http, house, **kwargs):

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
8 changes: 4 additions & 4 deletions openhivenpy/types/house.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ async def from_dict(cls, data: dict, http, rooms: typing.List[room.Room], **kwar

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down Expand Up @@ -231,14 +231,14 @@ async def from_dict(cls, data: dict, http, rooms: typing.List[room.Room], **kwar

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
return instance

Expand Down
8 changes: 4 additions & 4 deletions openhivenpy/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ async def from_dict(cls, data: dict, **kwargs):

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
return instance

Expand Down Expand Up @@ -235,14 +235,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
8 changes: 4 additions & 4 deletions openhivenpy/types/private_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down Expand Up @@ -287,14 +287,14 @@ async def from_dict(cls, data: dict, http, client_user, **kwargs):

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
8 changes: 4 additions & 4 deletions openhivenpy/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down Expand Up @@ -197,14 +197,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down
4 changes: 2 additions & 2 deletions openhivenpy/types/usertyping.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ async def from_dict(cls,

except ValidationError as e:
utils.log_validation_traceback(cls, e)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'",data=data)
raise errs.InvalidPassedDataError(f"Failed to perform validation in '{cls.__name__}'", data=data) from e

except Exception as e:
utils.log_traceback(msg=f"Traceback in '{cls.__name__}' Validation:",
suffix=f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
raise errs.InitializationError(f"Failed to initialise {cls.__name__} due to exception:\n"
f"{sys.exc_info()[0].__name__}: {e}!")
f"{sys.exc_info()[0].__name__}: {e}!") from e
else:
# Adding the http attribute for API interaction
instance._http = http
Expand Down

0 comments on commit 4271f2f

Please sign in to comment.