migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.06k stars 65 forks source link

Food for thought #396

Closed migueldeicaza closed 6 months ago

migueldeicaza commented 6 months ago

Should the GodotError enumeration adopt the Error protocol so that it can be thrown?

Matt-Is-Confused commented 6 months ago

Another feature beyond throwing is that Result uses error as well https://developer.apple.com/documentation/swift/result. Result is pretty useful in situations where throwing doesn't conform to the general flow of the program like networking or async/callbacks

migueldeicaza commented 6 months ago

Oh, very good point.

migueldeicaza commented 6 months ago

Oh, that was already the case, just as an extension.

I cleaned it up a little to make it more obvious, and so I do not trip next time I have this idea.

But I went ahead and added a debugDescription to enums as well, as a companion to the OptionSets that already implemented this feature.