ErrorMessageDto.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using Quadarax.Foundation.Core.Exceptions;
  3. namespace Quadarax.Foundation.Core.Data.Interface.Entity.Dto
  4. {
  5. public class ErrorMessageDto : IDto, IError
  6. {
  7. /// <summary>
  8. /// <inheritdoc cref="IError.Message"/>
  9. /// </summary>
  10. public string Message { get; set; }
  11. /// <summary>
  12. /// <inheritdoc cref="IError.Code"/>
  13. /// </summary>
  14. public int Code { get; set; }
  15. public string CallStack { get; set; }
  16. public ErrorMessageDto(){}
  17. public ErrorMessageDto(Exception exception, int code)
  18. {
  19. if (exception==null)
  20. throw new ArgumentNullException(nameof(exception));
  21. Message = exception.Message;
  22. Code = code;
  23. CallStack = exception.StackTrace;
  24. }
  25. public ErrorMessageDto(Exception exception)
  26. {
  27. if (exception==null)
  28. throw new ArgumentNullException(nameof(exception));
  29. Message = exception.Message;
  30. Code = exception.GetCode();
  31. CallStack = exception.StackTrace;
  32. }
  33. }
  34. }