Skip to content

Make Module.update() throw instead of crash for incompatible parameters#266

Merged
davidkoski merged 2 commits intoml-explore:mainfrom
louen:val/updatethrows
Sep 5, 2025
Merged

Make Module.update() throw instead of crash for incompatible parameters#266
davidkoski merged 2 commits intoml-explore:mainfrom
louen:val/updatethrows

Conversation

@louen
Copy link
Contributor

@louen louen commented Sep 4, 2025

Despite being a throwing function there are still cases where Module.update() will terminate with fatalError and thus crash the program, in case where the passed parameters are incompatible with the module's definition.

I think it is better to still throw in this case and let the caller decide what to do with this error, especially since there is already a non-throwing version of the function (which uses try! and thus crashes on any error) if the caller is not interested by error handling.

This PR proposes that all cases of fatalError in update() functions be replaced by cases of UpdateError. Care has been take so that the error message in the exception is similar to the one which was produced by fatalError.

Copy link
Collaborator

@davidkoski davidkoski left a comment

Choose a reason for hiding this comment

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

Looks good, I think this is a nice improvement!

@davidkoski davidkoski merged commit b89259d into ml-explore:main Sep 5, 2025
3 checks passed
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