DataStorageReadException.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Island.StandardLib.Exceptions
  5. {
  6. public class DataStorageReadException : Exception
  7. {
  8. public byte[] ErrorBits { get; private set; }
  9. public int ReadSize { get; private set; }
  10. public DataStorageReadException(int readSize, byte[] errorBits)
  11. {
  12. ReadSize = readSize;
  13. ErrorBits = errorBits;
  14. }
  15. public override string Message => $"DataStorageReadException: ReadAs: {ReadSize}Bits, SourceBits: {BitConverter.ToString(ErrorBits)}";
  16. public override string ToString() => Message;
  17. }
  18. public class DataStorageAutoException : Exception
  19. {
  20. public object ErrorObject { get; private set; }
  21. public Operation Operator;
  22. public enum Operation
  23. {
  24. ReadAuto, WriteAuto
  25. }
  26. public DataStorageAutoException(Operation opr, object obj)
  27. {
  28. ErrorObject = obj;
  29. Operator = opr;
  30. }
  31. public override string Message => $"DataStorageAutoException: {Operator}(object value) expect IStorable or StandardType, but got: {ErrorObject}";
  32. public override string ToString() => Message;
  33. }
  34. }