Pi: formatting cleanup, show database error

This commit is contained in:
Brian S. Stephan 2012-07-29 09:45:19 -05:00
parent dbcd367d66
commit b5d732cfd6
1 changed files with 7 additions and 2 deletions

View File

@ -104,10 +104,15 @@ class Pi(Module):
db.rollback()
self.log.error("database error doing pi stuff")
self.log.exception(e)
return self.reply(connection, event, "database error doing pi stuff")
return self.reply(connection, event,
"database error while estimating pi: {0:s}".format(str(e)))
finally: cur.close()
return self.reply(connection, event, "({0:.10f}, {1:.10f}) is {2}within the circle. pi is {5:.10f}. (i:{3:d} p:{4:d})".format(x, y, "" if inside else "not ", count_inside, count, pi))
return self.reply(connection, event,
"({0:.10f}, {1:.10f}) is {2}within the circle. "\
"pi is {5:.10f}. (i:{3:d} p:{4:d})".format(x, y,
"" if inside else "not ",
count_inside, count, pi))
# vi:tabstop=4:expandtab:autoindent
# kate: indent-mode python;indent-width 4;replace-tabs on;