KSP-KOS / KOS

Fully programmable autopilot mod for KSP. Originally By Nivekk
Other
697 stars 230 forks source link

volume:open(filename) throws encapsulation error when file doesn't exist #1536

Closed hvacengi closed 8 years ago

hvacengi commented 8 years ago

Instead of throwing an exception saying that the file does not exist, archive:open("filename"). will throw an error that the value could not be encapsulated. I suspect that open is returning null in this instance, which will throw that error message.

Dunbaratu commented 8 years ago

We recently had another issue where the inability to run FromPrimitive on a null value caused a "go report this to the devs" kind of error.

I know @erendrake in the past has disliked the idea of kerboscript having null values in it, but what if we make a subclass of Structure that stores a KOSNull and have FromPrimitive() convert into that when it is given a null to work with? there are cases where the null isn't seriously a problem because it's gone before the user actually sees it, and if we do have a place were we don't notice it, it does give us the chance to notice it, catch it, and give our own better error message instead of having C# itself barf because we tried converting a null into a Structure and can't do it.