提交 a47ed74a 编写于 作者: L luopengting

add error code for MaxCountExceededError, change exception used in summary_watcher

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