github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/sdk/python/sawtooth_sdk/processor/exceptions.py (about) 1 # Copyright 2016 Intel Corporation 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # ------------------------------------------------------------------------------ 15 16 17 class _TpResponseError(Exception): 18 """Parent class for errors that will be parsed and sent to a validator. 19 20 Args: 21 message (str): Standard error message to be logged or sent back 22 extended_data (bytes, optional): Byte-encoded data to be parsed later 23 by the app developer. Opaque to the validator and Sawtooth. 24 """ 25 26 def __init__(self, message, extended_data=None): 27 super().__init__(message) 28 29 if extended_data is not None and not isinstance(extended_data, bytes): 30 raise TypeError("extended_data must be byte-encoded") 31 self.extended_data = extended_data 32 33 34 class InvalidTransaction(_TpResponseError): 35 """Raised for an Invalid Transaction.""" 36 pass 37 38 39 class InternalError(_TpResponseError): 40 """Raised when an internal error occurs during transaction processing.""" 41 pass 42 43 44 class AuthorizationException(Exception): 45 """Raised when a authorization error occurs.""" 46 pass 47 48 49 class LocalConfigurationError(Exception): 50 """Raised when a log configuraiton error occurs.""" 51 pass