PostExceptions.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using System.Text;
  5. namespace InABox.Core.Postable
  6. {
  7. public class PostException : Exception
  8. {
  9. public PostException() : base() { }
  10. public PostException(string message) : base(message) { }
  11. }
  12. public class EmptyPostException : PostException
  13. {
  14. public EmptyPostException() { }
  15. }
  16. public class PostFailedMessageException : PostException
  17. {
  18. public PostFailedMessageException(string message): base(message) { }
  19. }
  20. public class MissingSettingException : PostException
  21. {
  22. public Type SettingsType { get; }
  23. public string Setting { get; set; }
  24. public MissingSettingException(Type settingsType, string setting): base($"Missing setting '{setting}'")
  25. {
  26. SettingsType = settingsType;
  27. Setting = setting;
  28. }
  29. }
  30. public class MissingSettingException<T> : MissingSettingException
  31. {
  32. public MissingSettingException(Expression<Func<T, object?>> setting) : base(typeof(T), CoreUtils.GetFullPropertyName(setting, ".")) { }
  33. }
  34. public class MissingSettingsException : PostException
  35. {
  36. public Type PostableType { get; }
  37. public MissingSettingsException(Type postableType) : base($"No PostableSettings for ${postableType}")
  38. {
  39. PostableType = postableType;
  40. }
  41. }
  42. public class RepostedException : PostException
  43. {
  44. public RepostedException() : base("Cannot process an item twice.")
  45. {
  46. }
  47. }
  48. public class PostCancelledException : PostException
  49. {
  50. public PostCancelledException() : base("Processing cancelled")
  51. {
  52. }
  53. }
  54. }