Improve the exception propagation logic
from typing import TYPE_CHECKING, Optional, Any, Tuple
from ..base.address import Address, ZERO_SCORE_ADDRESS
-from ..base.exception import ExceptionCode, IconServiceBaseException
+from ..base.exception import ExceptionCode, IconServiceBaseException, IconScoreException
from ..icon_constant import Revision
from ..iconscore.icon_score_constant import STR_FALLBACK
from ..ipc import MethodName
@@ -71,9 +71,13 @@ class InternalCall(object):
if status == ExceptionCode.OK:
return result
else:
- if Revision.to_value(context.revision) < Revision.ICON2 and \
- status == 1 and result == "NoAccount":
+ if Revision.to_value(context.revision) < Revision.ICON2 and status == 1:
+ if result == "NoAccount":
raise AttributeError("'NoneType' object has no attribute '_IconScoreBase__is_func_readonly'")
+ else:
+ raise Exception(result)
+ if status >= ExceptionCode.SCORE_ERROR:
+ raise IconScoreException(result, status - ExceptionCode.SCORE_ERROR)
raise IconServiceBaseException.create(result, status)
