Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

original errors #41

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/contracting/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,7 @@ def _abstract_function_call(
executor.sandbox.terminate()

if output['status_code'] == 1:
matches = re.match(r"Line \d+: (?P<exception_type>\w+) \(", output['result'])
try:
exception_type = matches.group('exception_type')
exception_class = getattr(___builtins___, exception_type)
raise exception_class(output['result'])
except AttributeError:
# If the exception type is not found, raise the output['result'] as a generic Exception.
raise Exception(output['result'])
raise output['result']

return output['result']

Expand Down
13 changes: 2 additions & 11 deletions src/contracting/execution/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from contracting.stdlib.bridge.random import Seeded
from contracting import constants
from loguru import logger
import re
from copy import deepcopy

import importlib
Expand Down Expand Up @@ -130,17 +131,7 @@ def execute(self, sender, contract_name, function_name, kwargs,
driver.commit()

except Exception as e:
tb = traceback.format_exc()
tb_info = traceback.extract_tb(e.__traceback__)
if contract_name == constants.SUBMISSION_CONTRACT_NAME:
filename, line, func, text = tb_info[-1]
line += 1
else:
filename, line, func, text = tb_info[-1]

result = f'Line {line}: {str(e.__class__.__name__)} ({str(e)})'
logger.error(str(e))
logger.error(tb)
result = e
status_code = 1

if auto_commit:
Expand Down
Loading