Skip to content

Commit

Permalink
Also catch RuntimeError exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Jun 23, 2024
1 parent ba3fadd commit f278a2e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/common/activity_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _forcePlugUpdate(self) -> None:
self._plugin = plugin
try:
self._plugin_name = plugins.getPluginName(*plugin)
except TypeError:
except (TypeError, RuntimeError):
self._plugin_name = ""
if len(plugin) == 1:
self._generator = plugin
Expand All @@ -116,7 +116,7 @@ def tick(self) -> None:
try:
if self._plugin_name != plugins.getPluginName(*self._plugin):
self._do_update = True
except TypeError:
except (TypeError, RuntimeError):
pass
if self._do_update:
# Manually update plugin using selection
Expand All @@ -136,7 +136,7 @@ def tick(self) -> None:
self._plugin = plugin
try:
self._plugin_name = plugins.getPluginName(*plugin)
except TypeError:
except (TypeError, RuntimeError):
self._plugin_name = ""
# Ignore typing because len(plugin) doesn't narrow types in
# mypy
Expand Down
4 changes: 2 additions & 2 deletions src/common/states/main_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def tick(self) -> None:
if isinstance(plug_idx, tuple):
try:
plug_id = plugins.getPluginName(*plug_idx)
except TypeError:
except (TypeError, RuntimeError):
# Plugin not valid
plug_id = ""
plug = common.ExtensionManager.plugins.get(
Expand Down Expand Up @@ -146,7 +146,7 @@ def processEvent(self, event: FlMidiMsg) -> None:
if isinstance(plug_idx, tuple):
try:
plug_id = plugins.getPluginName(*plug_idx)
except TypeError:
except (TypeError, RuntimeError):
# Plugin not valid
plug_id = ""
plug = common.ExtensionManager.plugins.get(
Expand Down
4 changes: 2 additions & 2 deletions src/common/util/api_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def isPluginVst(index: PluginIndex) -> bool:
"""
try:
return plugins.getParamCount(*index) > PARAM_CC_START
except TypeError:
except (TypeError, RuntimeError):
return False


Expand All @@ -139,7 +139,7 @@ def catchUnsafeOperation(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except TypeError as e:
except (TypeError, RuntimeError) as e:
if e.args != ("Operation unsafe at current time",):
raise e
return wrapper
Expand Down
2 changes: 1 addition & 1 deletion src/plugs/mapping_strategies/note_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def noteCallback(
) -> bool:
try:
i = channels.getChannelIndex(*getContext().activity.getGenerator())
except TypeError:
except (TypeError, RuntimeError):
# Index out of range - we're using a plugin from a different group
i = channels.channelNumber()
channels.midiNoteOn(
Expand Down
8 changes: 4 additions & 4 deletions src/plugs/special/activity_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def getActivityColor(activity: SafeIndex) -> Color:
# Generator -> channel color
try:
return Color.fromInteger(channels.getChannelColor(*activity))
except TypeError:
except (TypeError, RuntimeError):
# Prevent issues if we deleted stuff
return Color.BLACK
else:
# Effect -> track color
try:
return Color.fromInteger(mixer.getTrackColor(activity[0]))
except TypeError:
except (TypeError, RuntimeError):
return Color.BLACK


Expand All @@ -78,7 +78,7 @@ def getActivityName(activity: SafeIndex) -> str:
if len(activity) == 1:
try:
return channels.getChannelName(*activity)
except TypeError:
except (TypeError, RuntimeError):
# Prevent issues if we deleted stuff
return ""
else:
Expand All @@ -88,7 +88,7 @@ def getActivityName(activity: SafeIndex) -> str:
f"{mixer.getTrackName(activity[0])}: " # type: ignore
f"{plugins.getPluginName(*activity, True)}"
)
except TypeError:
except (TypeError, RuntimeError):
# Prevent issues if we deleted stuff
return ""

Expand Down
2 changes: 1 addition & 1 deletion src/plugs/windows/channel_rack/omni.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def drumPads(
idx = channels.getChannelIndex(
coordToIndex(control.getShadow())
)
except TypeError: # Index out of range
except (TypeError, RuntimeError): # Index out of range
return True
channels.midiNoteOn(
idx,
Expand Down

0 comments on commit f278a2e

Please sign in to comment.