Add error logging
This commit is contained in:
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,6 +291,7 @@ class OnionrUtils:
|
|||||||
for i in blocks:
|
for i in blocks:
|
||||||
if len (i) == 0:
|
if len (i) == 0:
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
with open('data/blocks/' + i + '.dat', 'r') as potentialMessage:
|
with open('data/blocks/' + i + '.dat', 'r') as potentialMessage:
|
||||||
message = potentialMessage.read()
|
message = potentialMessage.read()
|
||||||
if message.startswith('-pm-'):
|
if message.startswith('-pm-'):
|
||||||
@ -302,4 +303,6 @@ class OnionrUtils:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
logger.info('Recieved message: ' + message.decode())
|
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
Block a user