ExceptionExc.cs 447 B

1234567891011121314151617181920
  1. using System;
  2. namespace Quadarax.Foundation.Core.Exceptions
  3. {
  4. public static class ExceptionExc
  5. {
  6. public static int GetCode(this Exception e)
  7. {
  8. if (!e.Data.Contains("Code"))
  9. return -1;
  10. return int.Parse(e.Data["Code"]?.ToString() ?? "-1");
  11. }
  12. public static void SetCode(this Exception e, int code)
  13. {
  14. e.Data.Add("Code", code);
  15. }
  16. }
  17. }