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