Add error logging
parent
86a2c0d6d0
commit
ded179bcad
|
@ -216,9 +216,11 @@ def warn(data, timestamp=True):
|
|||
log('!', data, colors.fg.orange, timestamp=timestamp)
|
||||
|
||||
# error: when only one function, module, or process of the program encountered a problem and must stop
|
||||
def error(data, timestamp=True):
|
||||
def error(data, error=None, timestamp=True):
|
||||
if get_level() <= LEVEL_ERROR:
|
||||
log('-', data, colors.fg.red, timestamp=timestamp)
|
||||
if not error is None:
|
||||
debug('Error details: ' + str(error))
|
||||
|
||||
# fatal: when the something so bad has happened that the prorgam must stop
|
||||
def fatal(data, timestamp=True):
|
||||
|
|
|
@ -291,15 +291,18 @@ class OnionrUtils:
|
|||
for i in blocks:
|
||||
if len (i) == 0:
|
||||
continue
|
||||
with open('data/blocks/' + i + '.dat', 'r') as potentialMessage:
|
||||
message = potentialMessage.read()
|
||||
if message.startswith('-pm-'):
|
||||
try:
|
||||
message = self._core._crypto.pubKeyDecrypt(message.replace('-pm-', ''), encodedData=True, anonymous=True)
|
||||
except nacl.exceptions.CryptoError as e:
|
||||
#logger.debug('Unable to decrypt ' + i)
|
||||
#logger.debug(str(e))
|
||||
pass
|
||||
else:
|
||||
logger.info('Recieved message: ' + message.decode())
|
||||
try:
|
||||
with open('data/blocks/' + i + '.dat', 'r') as potentialMessage:
|
||||
message = potentialMessage.read()
|
||||
if message.startswith('-pm-'):
|
||||
try:
|
||||
message = self._core._crypto.pubKeyDecrypt(message.replace('-pm-', ''), encodedData=True, anonymous=True)
|
||||
except nacl.exceptions.CryptoError as e:
|
||||
#logger.debug('Unable to decrypt ' + i)
|
||||
#logger.debug(str(e))
|
||||
pass
|
||||
else:
|
||||
logger.info('Recieved message: ' + message.decode())
|
||||
except Exception as error:
|
||||
logger.error('Failed to open block ' + str(i) + '.', error=error)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue