暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ExceptionUtils.cs 673B

123456789101112131415161718192021
  1. using System;
  2. using System.Runtime.Serialization;
  3. namespace UnityEngine.UI.Tests.Utils
  4. {
  5. class ExceptionUtils
  6. {
  7. public static void PreserveStackTrace(Exception e)
  8. {
  9. var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
  10. var mgr = new ObjectManager(null, ctx);
  11. var si = new SerializationInfo(e.GetType(), new FormatterConverter());
  12. e.GetObjectData(si, ctx);
  13. mgr.RegisterObject(e, 1, si); // prepare for SetObjectData
  14. mgr.DoFixups(); // ObjectManager calls SetObjectData
  15. // voila, e is unmodified save for _remoteStackTraceString
  16. }
  17. }
  18. }