Skip to content

Conversation

@jakzie2
Copy link
Contributor

@jakzie2 jakzie2 commented Apr 25, 2022

During importing, loading and completing of mods, all exceptions get caught and reraised with a name of the mod which caused them included in the error message. Original traceback is preserved.

Visibly showing a name of the mod causing the startup error should be very helpful for normal players who don't want to dig through the traceback and just want to know which mod author to scream at.

update_modtools(args.url)


def mod_error(phase, mod_name, e):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change the signature so it's called as mod_error_check(lamba: importlib.import_module(mod), state="importing")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or with but I'm not sure if that's py2 compatible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would I use it in this case tho where the following code needs the return value?
Could use a nested function but that would make it less clean than it is now.

try:
    mod_object = importlib.import_module(mod)
except Exception as e:
     mod_error("importing", mod, e)

@muddyfish muddyfish merged commit 65cd1cf into AWSW-Modding:develop Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants