Skip to content

Commit 524965a

Browse files
committed
If an exception is thrown while accessing a variable via reflection, a more detailed error message is logged
1 parent efad9fa commit 524965a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Plugins/AssetUsageDetector/Editor/VariableGetter.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Reflection;
3+
using System.Text;
34
using UnityEngine;
45

56
namespace AssetUsageDetectorNamespace
@@ -39,7 +40,12 @@ public object Get( object obj )
3940
}
4041
catch( Exception e )
4142
{
42-
Debug.LogException( e );
43+
StringBuilder sb = Utilities.stringBuilder;
44+
sb.Length = 0;
45+
sb.Append( "Error while getting the value of (" ).Append( IsProperty ? ( (PropertyInfo) variable ).PropertyType : ( (FieldInfo) variable ).FieldType ).Append( ") " )
46+
.Append( variable.DeclaringType ).Append( "." ).Append( Name ).Append( ": " ).Append( e );
47+
48+
Debug.LogError( sb.ToString() );
4349
return null;
4450
}
4551
}

0 commit comments

Comments
 (0)