AppException.cs 819 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Globalization;
  3. namespace MTWorkHR.Core.Global
  4. {
  5. public class AppException : Exception
  6. {
  7. public readonly string ErrorNumber;
  8. public readonly ExceptionEnum errorNumber;
  9. public string ErrorMessage = "";
  10. public AppException(string errorMessage) : base(errorMessage) {
  11. ErrorMessage = errorMessage;
  12. }
  13. public AppException(ExceptionEnum errorNumber,params object?[] args) : base()
  14. {
  15. this.errorNumber = errorNumber;
  16. AppExceptions.ExceptionMessages.TryGetValue((int)this.errorNumber, out this.ErrorMessage);
  17. try
  18. {
  19. this.ErrorMessage = string.Format(this.ErrorMessage, args);
  20. }
  21. catch
  22. {
  23. }
  24. }
  25. }
  26. }