提交 a47ed74a 编写于 作者: L luopengting

add error code for MaxCountExceededError, change exception used in summary_watcher

上级 edb6dc56
......@@ -83,10 +83,10 @@ class NodeNotInGraphError(MindInsightException):
http_code=400)
class MaxCountExceededException(MindInsightException):
class MaxCountExceededError(MindInsightException):
"""Count is out of limit."""
def __init__(self):
error_msg = "Count is out of limit."
super(MaxCountExceededException, self).__init__(DataVisualErrors.NODE_NOT_IN_GRAPH_ERROR,
error_msg,
http_code=400)
super(MaxCountExceededError, self).__init__(DataVisualErrors.MAX_COUNT_EXCEEDED_ERROR,
error_msg,
http_code=400)
......@@ -22,7 +22,7 @@ from pathlib import Path
from mindinsight.datavisual.common.log import logger
from mindinsight.datavisual.common.validation import Validation
from mindinsight.datavisual.utils.tools import Counter
from mindinsight.utils.exceptions import ParamValueError
from mindinsight.datavisual.common.exceptions import MaxCountExceededError
from mindinsight.utils.exceptions import FileSystemPermissionError
......@@ -87,7 +87,7 @@ class SummaryWatcher:
break
try:
counter.add()
except ParamValueError:
except MaxCountExceededError:
logger.info('Stop further scanning due to overall is False and '
'number of scanned files exceeds upper limit.')
break
......@@ -132,7 +132,7 @@ class SummaryWatcher:
break
try:
counter.add()
except ParamValueError:
except MaxCountExceededError:
logger.info('Stop further scanning due to overall is False and '
'number of scanned files exceeds upper limit.')
break
......
......@@ -20,7 +20,7 @@ import os
from numbers import Number
from urllib.parse import unquote
from mindinsight.datavisual.common.exceptions import MaxCountExceededException
from mindinsight.datavisual.common.exceptions import MaxCountExceededError
from mindinsight.utils import exceptions
_IMG_EXT_TO_MIMETYPE = {
......@@ -165,5 +165,5 @@ class Counter:
def add(self, value=1):
"""Add value."""
if self._max_count is not None and self._count + value > self._max_count:
raise MaxCountExceededException()
raise MaxCountExceededError()
self._count += value
......@@ -50,7 +50,7 @@ class DataVisualErrors(Enum):
"""Enum definition for datavisual errors."""
RESTFUL_API_NOT_EXIST = 1
REQUEST_METHOD_NOT_ALLOWED = 2
SUMMARY_LOG_CONTENT_INVALID = 3
MAX_COUNT_EXCEEDED_ERROR = 3
CRC_FAILED = 4
TRAIN_JOB_NOT_EXIST = 5
SUMMARY_LOG_PATH_INVALID = 6
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册