hikyuu2/hikyuu/util/check.py

26 lines
629 B
C++
Raw Normal View History

2020-08-22 00:48:20 +08:00
#!/usr/bin/python
# -*- coding: utf8 -*-
# cp936
#==========================================================
# History
# 1. 20200821, Added by fasiondog
#==========================================================
class CheckError(Exception):
def __init__(self, expression, message):
self.expression = expression
self.message = message
def __str__(self):
return self.message
2020-08-22 19:15:31 +08:00
def checkif(expression, message, excepion=None, **kwargs):
2020-08-22 00:48:20 +08:00
if expression:
if excepion is None:
raise CheckError(expression, message)
else:
2020-08-22 19:15:31 +08:00
raise excepion(message, **kwargs)