Throw exception when trying to resolve a userdata type that's not registered, instead of just returning null
This commit is contained in:
parent
d13eb7d2d5
commit
d830929290
|
@ -43,8 +43,10 @@ namespace PorygonSharp.EvalValues
|
|||
case TypeCode.Object:
|
||||
if (typeof(IList).IsAssignableFrom(type))
|
||||
return CreateListEvalValue((IList)o, type);
|
||||
if (!UserDataHandler.IsTypeRegistered(type))
|
||||
return null;
|
||||
if (!UserDataHandler.IsTypeRegistered(type) && !UserDataHandler.TryResolveType(type))
|
||||
{
|
||||
throw new Exception($"Type is not registered for use: {type.FullName}");
|
||||
}
|
||||
var typeHash = UserDataHandler.GetTypeId(type);
|
||||
var handle = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);
|
||||
return new EvalValue(CreateUserDataEvalValue(typeHash, GCHandle.ToIntPtr(handle)));
|
||||
|
|
Loading…
Reference in New Issue