C# ActiveVessel throws System.ArgumentNullException
Grille opened this issue · 2 comments
What happened?
When using the ActiveVessel property while no vehicle is active; this exception is thrown:
System.ArgumentNullException: 'Value cannot be null.
Parameter name: vessel
Server stack trace:
at KRPC.SpaceCenter.Services.Vessel..ctor (Vessel vessel) [0x00012] in <d8566df5220a4070afa44bd2ecc53aa8>:0
I’m not sure if this is what’s supposed to happen? If that’s excepected I would have expected an more descriptive error message. Also an alternative bool TryGetActiveVessel(out Vessel vessel)
method would be nice then.
Also, once it’s clear what this is, I might be willing to try to contribute myself ^^
How can someone else reproduce it?
Use ActiveVessel while none is active in game.
What is your environment?
c#
krpc 0.5.4
Anything else we need to know?
No response
This issue stems from a missing Nullable = true
for [KRPCProperty]
here as well as a missing null check for FlightGlobals.ActiveVessel
in the property's get
ter. This is a bug in kRPC and thus the error message isn't the greatest but honestly I'm not sure how it could be made better.
If that's enough for you to make the PR (and you still wish to), go ahead. If not, I'll do so.