exception.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. exception: Exception classes for the MMGen suite
  20. """
  21. class MMGenError(Exception):
  22. def __init__(self, errno, strerror, stdout):
  23. self.mmcode = errno
  24. self.stdout = stdout
  25. super().__init__(strerror)
  26. def __repr__(self):
  27. return f'{type(self).__name__}({self.mmcode}):\n{self}'
  28. class MMGenSystemExit(MMGenError):
  29. def __repr__(self):
  30. return f'{type(self).__name__}({self.mmcode}): {self}'
  31. # 1: no hl, message only
  32. class UserNonConfirmation(Exception): mmcode = 1
  33. class BadAgeFormat(Exception): mmcode = 1
  34. class BadFilename(Exception): mmcode = 1
  35. class BadFileExtension(Exception): mmcode = 1
  36. class SocketError(Exception): mmcode = 1
  37. class UserAddressNotInWallet(Exception): mmcode = 1
  38. class MnemonicError(Exception): mmcode = 1
  39. class RangeError(Exception): mmcode = 1
  40. class FileNotFound(Exception): mmcode = 1
  41. class InvalidPasswdFormat(Exception): mmcode = 1
  42. class CfgFileParseError(Exception): mmcode = 1
  43. class UserOptError(Exception): mmcode = 1
  44. class CmdlineOptError(Exception): mmcode = 1
  45. class NoLEDSupport(Exception): mmcode = 1
  46. class MsgFileFailedSID(Exception): mmcode = 1
  47. class TestSuiteException(Exception): mmcode = 1
  48. class TestSuiteSpawnedScriptException(Exception): mmcode = 1
  49. # 2: yellow hl, message only
  50. class InvalidTokenAddress(Exception): mmcode = 2
  51. class UnrecognizedTokenSymbol(Exception): mmcode = 2
  52. class TokenNotInBlockchain(Exception): mmcode = 2
  53. class TokenNotInWallet(Exception): mmcode = 2
  54. class BadTwComment(Exception): mmcode = 2
  55. class BadTwLabel(Exception): mmcode = 2
  56. class BaseConversionError(Exception): mmcode = 2
  57. class BaseConversionPadError(Exception): mmcode = 2
  58. class TransactionChainMismatch(Exception):mmcode = 2
  59. class ObjectInitError(Exception): mmcode = 2
  60. class ClassFlagsError(Exception): mmcode = 2
  61. class ExtensionModuleError(Exception): mmcode = 2
  62. class MoneroMMGenTXFileParseError(Exception): mmcode = 2
  63. class AutosignTXError(Exception): mmcode = 2
  64. class MMGenImportError(Exception): mmcode = 2
  65. # 3: yellow hl, 'MMGen Error' + exception + message
  66. class RPCFailure(Exception): mmcode = 3
  67. class RPCChainMismatch(Exception): mmcode = 3
  68. class BadTxSizeEstimate(Exception): mmcode = 3
  69. class MaxInputSizeExceeded(Exception): mmcode = 3
  70. class MaxFileSizeExceeded(Exception): mmcode = 3
  71. class MaxFeeExceeded(Exception): mmcode = 3
  72. class WalletFileError(Exception): mmcode = 3
  73. class HexadecimalStringError(Exception): mmcode = 3
  74. class SeedLengthError(Exception): mmcode = 3
  75. class PrivateKeyError(Exception): mmcode = 3
  76. class MMGenCalledProcessError(Exception): mmcode = 3
  77. class TestSuiteFatalException(Exception): mmcode = 3
  78. # 4: red hl, 'MMGen Fatal Error' + exception + message
  79. class BadMMGenTxID(Exception): mmcode = 4
  80. class IllegalWitnessFlagValue(Exception): mmcode = 4
  81. class TxHexParseError(Exception): mmcode = 4
  82. class TxHexMismatch(Exception): mmcode = 4
  83. class SubSeedNonceRangeExceeded(Exception): mmcode = 4