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:
|
case TypeCode.Object:
|
||||||
if (typeof(IList).IsAssignableFrom(type))
|
if (typeof(IList).IsAssignableFrom(type))
|
||||||
return CreateListEvalValue((IList)o, type);
|
return CreateListEvalValue((IList)o, type);
|
||||||
if (!UserDataHandler.IsTypeRegistered(type))
|
if (!UserDataHandler.IsTypeRegistered(type) && !UserDataHandler.TryResolveType(type))
|
||||||
return null;
|
{
|
||||||
|
throw new Exception($"Type is not registered for use: {type.FullName}");
|
||||||
|
}
|
||||||
var typeHash = UserDataHandler.GetTypeId(type);
|
var typeHash = UserDataHandler.GetTypeId(type);
|
||||||
var handle = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);
|
var handle = GCHandle.Alloc(o, GCHandleType.WeakTrackResurrection);
|
||||||
return new EvalValue(CreateUserDataEvalValue(typeHash, GCHandle.ToIntPtr(handle)));
|
return new EvalValue(CreateUserDataEvalValue(typeHash, GCHandle.ToIntPtr(handle)));
|
||||||
|
|
Loading…
Reference in New Issue