Skip to content

Commit

Permalink
fix: log exception type
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeCrassous committed Oct 26, 2020
1 parent 6e71fae commit e89df0a
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fix new mesh part not linked to its collection after mesh separate
- Remove logging of meaningless ReferenceError messages
- Fix error when setting datablock reference after initial synchronization (e.g. TextureNodeImage.image, ArrayModifier.object_offset, Scene.camera)
- Add exception type when logging an exception


# 0.17.0 (2020-10-15)
Expand Down
4 changes: 2 additions & 2 deletions mixer/bl_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def execute(self, context):
try:
connect()
except Exception as e:
self.report({"ERROR"}, f"mixer.connect error : {e}")
self.report({"ERROR"}, f"mixer.connect error : {e!r}")
return {"CANCELLED"}

self.report({"INFO"}, f'Connected to "{prefs.host}:{prefs.port}" ...')
Expand Down Expand Up @@ -331,7 +331,7 @@ def execute(self, context):
try:
connect()
except Exception as e:
self.report({"ERROR"}, f"vrtist.launch connect error : {e}")
self.report({"ERROR"}, f"vrtist.launch connect error : {e!r}")
return {"CANCELLED"}

logger.warning("LaunchVRtistOperator.execute({mixer_prefs.room})")
Expand Down
2 changes: 1 addition & 1 deletion mixer/bl_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def update_panels_category(self, context):
bpy.utils.register_class(panel)

except Exception as e:
logger.error(f"Updating Panel category has failed {e}")
logger.error(f"Updating Panel category has failed {e!r}")


classes = (ROOM_UL_ItemRenderer, MixerSettingsPanel, VRtistSettingsPanel)
Expand Down
8 changes: 4 additions & 4 deletions mixer/blender_client/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def build_collection_removed(data):
bpy.data.collections.remove(collection)
except Exception as e:
logger.info("build_remove_collection_from_scene: exception during unlink... ")
logger.info(f"... {e} ")
logger.info(f"... {e!r} ")


def send_add_collection_to_collection(client: Client, parent_collection_name, collection_name):
Expand Down Expand Up @@ -132,11 +132,11 @@ def build_collection_to_collection(data):
logger.info(f"build_collection_to_collection(): parent {parent_name}, child {child_name}...")
logger.info("... Exception during parent.children.link() ...")
logger.info("... Safe in experimental_sync ...")
logger.info(f"... {e}")
logger.info(f"... {e!r}")
else:
logger.warning(f"build_collection_to_collection(): parent {parent_name}, child {child_name}...")
logger.warning("... Exception during parent.children.link() ...")
logger.warning(f"... {e}")
logger.warning(f"... {e!r}")


def send_remove_collection_from_collection(client: Client, parent_collection_name, collection_name):
Expand Down Expand Up @@ -221,7 +221,7 @@ def build_remove_object_from_collection(data):
collection.objects.unlink(object_)
except Exception as e:
logger.info("build_remove_object_from_collection: exception during unlink... ")
logger.info(f"... {e} ")
logger.info(f"... {e!r} ")


def send_collection_instance(client: Client, obj):
Expand Down
8 changes: 4 additions & 4 deletions mixer/blender_client/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def window():
logger.warning(f"... OK. Remaining scenes: {bpy.data.scenes.keys()}")
return True
except RuntimeError as e:
logger.warning(f"delete_scene {scene}: exception {e}")
logger.warning(f"delete_scene {scene}: exception {e!r}")
return False


Expand Down Expand Up @@ -151,7 +151,7 @@ def build_collection_to_scene(data):
logger.info(f"build_collection_to_scene(): scene {scene_name}, collection {collection_name}...")
logger.info("... Exception during scene.collection.children.link() ...")
logger.info("... Safe in experimental_sync ...")
logger.info(f"... {e}")
logger.info(f"... {e!r}")
else:
raise
share_data.update_collection_temporary_visibility(collection_name)
Expand Down Expand Up @@ -183,7 +183,7 @@ def build_remove_collection_from_scene(data):
scene.collection.children.unlink(collection)
except Exception as e:
logger.info("build_remove_collection_from_scene: exception during unlink... ")
logger.info(f"... {e} ")
logger.info(f"... {e!r} ")


def send_add_object_to_vrtist(client: Client, scene_name: str, obj_name: str):
Expand Down Expand Up @@ -240,4 +240,4 @@ def build_remove_object_from_scene(data):
scene.collection.objects.unlink(object_)
except Exception as e:
logger.info("build_remove_object_from_scene: exception during unlink... ")
logger.info(f"... {e} ")
logger.info(f"... {e!r} ")
2 changes: 1 addition & 1 deletion mixer/blender_data/aos_soa_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def save_array(self, aos: T.bpy_prop_collection, member_name, array_: array.arra
except RuntimeError as e:
logger.error(f"saving soa {aos}.{member_name} failed")
logger.error(f"... member size: {len(aos)}, array: ('{array_.typecode}', {len(array_)})")
logger.error(f"... exception {e}")
logger.error(f"... exception {e!r}")

def apply(
self, parent: T.bpy_prop_collection, key: str, delta: Optional[DeltaUpdate], context: Context, to_blender=True
Expand Down
2 changes: 1 addition & 1 deletion mixer/blender_data/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def diff_attribute(
return DeltaUpdate(blender_value)

except Exception as e:
logger.warning(f"diff exception for attr: {e}")
logger.warning(f"diff exception for attr: {e!r}")
return None

return None
6 changes: 3 additions & 3 deletions mixer/blender_data/datablock_collection_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def remove_datablock(self, proxy: DatablockProxy, datablock: T.ID):
# but deleting the light on this side has already deleted the object.
# Alternatively we could try to sort messages on the sender side
logger.warning(f"Exception during remove_datablock for {proxy}")
logger.warning(f"... {e}")
logger.warning(f"... {e!r}")
uuid = proxy.mixer_uuid()
del self._data[uuid]

Expand Down Expand Up @@ -220,7 +220,7 @@ def update(self, diff: BpyPropCollectionDiff, context: Context) -> Changeset:
except MaxDepthExceeded as e:
logger.error(f"MaxDepthExceeded while loading {collection_name}[{name}]:")
logger.error("... Nested attribute depth is too large: ")
logger.error(f"... {e}")
logger.error(f"... {e!r}")
except Exception:
logger.error(f"Exception while loading {collection_name}[{name}]:")
for line in traceback.format_exc().splitlines():
Expand Down Expand Up @@ -401,7 +401,7 @@ def apply(
except Exception as e:
logger.warning(f"DatablockCollectionProxy.apply(). Processing {ref_delta} to_blender {to_blender}")
logger.warning(f"... for {collection}[{k}]")
logger.warning(f"... Exception: {e}")
logger.warning(f"... Exception: {e!r}")
logger.warning("... Update ignored")
continue

Expand Down
2 changes: 1 addition & 1 deletion mixer/blender_data/datablock_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def apply_to_proxy(
except Exception as e:
logger.warning(f"apply_to_proxy(). Processing {delta}")
logger.warning(f"... for {datablock}.{k}")
logger.warning(f"... Exception: {e}")
logger.warning(f"... Exception: {e!r}")
logger.warning("... Update ignored")
continue
finally:
Expand Down
2 changes: 1 addition & 1 deletion mixer/blender_data/datablock_ref_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def save(self, container: Union[T.ID, T.bpy_prop_collection], key: str, context:
logger.warning(
f"DatablockRefProxy.save() exception while saving {ref_target} into {container}[{key}]..."
)
logger.warning(f"...{e}")
logger.warning(f"...{e!r}")
else:
# is there a case for this ?
logger.warning(
Expand Down
2 changes: 1 addition & 1 deletion mixer/blender_data/mesh_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def apply(
except Exception as e:
logger.warning(f"Struct.apply(). Processing {member_delta}")
logger.warning(f"... for {struct}.{k}")
logger.warning(f"... Exception: {e}")
logger.warning(f"... Exception: {e!r}")
logger.warning("... Update ignored")
continue
finally:
Expand Down
4 changes: 2 additions & 2 deletions mixer/blender_data/specifics.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def bpy_data_ctor(collection_name: str, proxy: DatablockProxy, context: Any) ->
image = collection.load(path)
except RuntimeError as e:
logger.warning(f'Cannot load image at path "{path}". Exception: ')
logger.warning(f"... {e}")
logger.warning(f"... {e!r}")
return None
# we may have received an ID named xxx.001 although filepath is xxx, so fix it now
image.name = proxy.data("name")
Expand Down Expand Up @@ -209,7 +209,7 @@ def bpy_data_ctor(collection_name: str, proxy: DatablockProxy, context: Any) ->
id_ = collection.new(name)
except TypeError as e:
logger.error(f"Exception while calling : bpy.data.{collection_name}.new({name})")
logger.error(f"TypeError : {e}")
logger.error(f"TypeError : {e!r}")
return None

return id_
Expand Down
4 changes: 2 additions & 2 deletions mixer/blender_data/struct_collection_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def apply(
except Exception as e:
logger.warning(f"StructCollectionProxy.apply(). Processing {delta}")
logger.warning(f"... for {collection}[{i}]")
logger.warning(f"... Exception: {e}")
logger.warning(f"... Exception: {e!r}")
logger.warning("... Update ignored")
continue
else:
Expand Down Expand Up @@ -299,7 +299,7 @@ def apply(
except Exception as e:
logger.warning(f"StructCollectionProxy.apply(). Processing {delta}")
logger.warning(f"... for {collection}[{k}]")
logger.warning(f"... Exception: {e}")
logger.warning(f"... Exception: {e!r}")
logger.warning("... Update ignored")
continue
finally:
Expand Down
2 changes: 1 addition & 1 deletion mixer/blender_data/struct_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def apply(
except Exception as e:
logger.warning(f"Struct.apply(). Processing {member_delta}")
logger.warning(f"... for {struct}.{k}")
logger.warning(f"... Exception: {e}")
logger.warning(f"... Exception: {e!r}")
logger.warning("... Update ignored")
continue
finally:
Expand Down
4 changes: 2 additions & 2 deletions mixer/blender_data/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def bl_equals(attr_a, attr_b, msg=None, skip_name=False, synchronized_properties
)
except failureException as e:
raise failureException(
f'{e}\nDifferent values for collection items at key "{key}" : {attr_a_i} and {attr_b_i}'
f'{e!r}\nDifferent values for collection items at key "{key}" : {attr_a_i} and {attr_b_i}'
) from None
if not equal:
raise failureException(
Expand All @@ -122,7 +122,7 @@ def bl_equals(attr_a, attr_b, msg=None, skip_name=False, synchronized_properties
)
except failureException as e:
raise failureException(
f'{e}\nDifferent values for struct items at key "{name}" : {attr_a_i} and {attr_b_i}'
f'{e!r}\nDifferent values for struct items at key "{name}" : {attr_a_i} and {attr_b_i}'
) from None
if not equal:
raise failureException(f'Different values for struct items at key "{name}" : {attr_a_i} and {attr_b_i}')
Expand Down
2 changes: 1 addition & 1 deletion mixer/broadcaster/apps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def interactive_loop(args):
else:
pass
except Exception as e:
logger.error(f"Exception: {e}", exc_info=True)
logger.error(f"Exception: {e!r}", exc_info=True)


def main():
Expand Down
2 changes: 1 addition & 1 deletion mixer/broadcaster/apps/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _join_room(command: common.Command):
try:
self._server.join_room(self, room_name)
except Exception as e:
_send_error(f"{e}")
_send_error(f"{e!r}")

def _leave_room(command: common.Command):
if self.room is None:
Expand Down
6 changes: 3 additions & 3 deletions tests/mixer_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def assert_matches(self):
# time.sleep(1)
self._receiver.disconnect_mixer()
except Exception as e:
raise self.failureException(f"Exception during disconnect():\n{e}\nPossible Blender crash") from None
raise self.failureException(f"Exception during disconnect():\n{e!r}\nPossible Blender crash") from None

# wait for disconnect before killing the server. Avoids a disconnect operator context error message
time.sleep(0.5)
Expand Down Expand Up @@ -383,14 +383,14 @@ def disconnect(self):
for blender in self._blenders:
blender.disconnect_mixer()
except Exception as e:
raise self.failureException(f"Exception {e} during disconnect_mixer(). Possible Blender crash")
raise self.failureException(f"Exception {e!r} during disconnect_mixer(). Possible Blender crash")

def send_string(self, s: str, to: Optional[int] = 0, sleep: float = 0.5):
try:
self._blenders[to].send_string(s, sleep)
except Exception as e:
raise self.failureException(
f"Exception {e}\n" "during send command :\n" "{s}\n" "to Blender {to}.\n" "Possible Blender crash"
f"Exception {e!r}\n" "during send command :\n" "{s}\n" "to Blender {to}.\n" "Possible Blender crash"
)

def send_strings(self, strings: List[str], to: Optional[int] = 0, sleep: float = 0.5):
Expand Down
4 changes: 2 additions & 2 deletions tests/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def start(self, args, kwargs):
logger.info("subprocess.popen: success")
except Exception as e:
logger.error("Python.start(): Exception raised during subprocess.Popen(): ")
logger.error(f"{e}")
logger.error(f"{e!r}")
logger.error(f"args: {args}")
logger.error(f"kwargs: {kwargs}")
logger.error(f"command line: {self.command_line}")
Expand Down Expand Up @@ -294,7 +294,7 @@ def _test_connect(self, timeout: float = 0.0):
raise
if waited >= timeout:
message = f"Cannot connect to broadcaster at {self.host}{self.port} after {waited} seconds.\n"
f"Exception: {e}\n"
f"Exception: {e!r}\n"
f"Command line was: {self.command_line}"
raise RuntimeError(message)
delay = 0.2
Expand Down

0 comments on commit e89df0a

Please sign in to comment.