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

[SM64] Add better exception processing to combined exporter #496

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fast64_internal/sm64/sm64_collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def exportCollisionCommon(obj, transformMatrix, includeSpecials, includeChildren
try:
addCollisionTriangles(tempObj, collisionDict, includeChildren, transformMatrix, areaIndex)
if not collisionDict:
raise PluginError("No collision data to export")
raise PluginError("No collision data to export", PluginError.exc_warn)
cleanupDuplicatedObjects(allObjs)
obj.select_set(True)
bpy.context.view_layer.objects.active = obj
Expand Down
2 changes: 1 addition & 1 deletion fast64_internal/sm64/sm64_geolayout_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def convertObjectToGeolayout(
convertTextureData,
)
if is_actor and not meshGeolayout.has_data():
raise PluginError("No gfx data to export, gfx export cancelled")
raise PluginError("No gfx data to export, gfx export cancelled", PluginError.exc_warn)
except Exception as e:
raise Exception(str(e))
finally:
Expand Down
10 changes: 6 additions & 4 deletions fast64_internal/sm64/sm64_objects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math, bpy, mathutils
import os
import traceback
from bpy.utils import register_class, unregister_class
from re import findall, sub
from pathlib import Path
Expand Down Expand Up @@ -1863,7 +1864,7 @@ def execute_col(self, props, obj):
bpy.ops.object.sm64_export_collision(export_obj=obj.name)
except Exception as exc:
# pass on multiple export, throw on singular
if not props.export_all_selected:
if not props.export_all_selected or not PluginError.check_exc_warn(exc):
raise Exception(exc) from exc

# writes model.inc.c, geo.inc.c file, geo_header.h
Expand All @@ -1883,10 +1884,10 @@ def execute_gfx(self, props, context, obj, index):
if props.export_script_loads and props.model_id != 0:
self.export_model_id(context, props, index)
self.export_script_load(context, props)
except Exception as e:
except Exception as exc:
# pass on multiple export, throw on singular
if not props.export_all_selected:
raise Exception(e)
if not props.export_all_selected or not PluginError.check_exc_warn(exc):
raise Exception(exc)

def execute(self, context):
props = context.scene.fast64.sm64.combined_export
Expand All @@ -1909,6 +1910,7 @@ def execute(self, context):
props.context_obj = None
# you've done it!~
self.report({"INFO"}, "Success!")

return {"FINISHED"}


Expand Down
17 changes: 16 additions & 1 deletion fast64_internal/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@


class PluginError(Exception):
pass
# arguments for exception processing
exc_halt = "exc_halt"
exc_warn = "exc_warn"

"""
because exceptions generally go through multiple funcs
and layers, the easiest way to check if we have an exception
of a certain type is to check for our input string
"""

@classmethod
def check_exc_warn(self, exc):
for arg in exc.args:
if type(arg) is str and self.exc_warn in arg:
return True
return False


class VertexWeightError(PluginError):
Expand Down