Decode error (#1488)

* Fix mypy version

* Add error handling exception

* black

* Fix mypy issue
pull/1489/head
Nikhil Parasaram 3 years ago committed by GitHub
parent 588bc2e0f6
commit 12a66e601d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      mythril/ethereum/util.py

@ -5,12 +5,14 @@ import json
import sys
import os
import platform
import logging
import solc
from pathlib import Path
from subprocess import PIPE, Popen
import solc
from ethereum.abi import encode_abi, encode_int, method_id
from ethereum.utils import zpad
from json.decoder import JSONDecodeError
from mythril.exceptions import CompilerError
from semantic_version import Version
@ -18,6 +20,8 @@ if sys.version_info[1] >= 6:
import solcx
from solcx.exceptions import SolcNotInstalled
log = logging.getLogger(__name__)
def safe_decode(hex_encoded_string):
"""
@ -76,7 +80,11 @@ def get_solc_json(file, solc_binary="solc", solc_settings_json=None):
out = stdout.decode("UTF-8")
result = json.loads(out)
try:
result = json.loads(out)
except JSONDecodeError as e:
log.error(f"Encountered a decode error, stdout:{out}, stderr: {stderr}")
raise e
for error in result.get("errors", []):
if error["severity"] == "error":

Loading…
Cancel
Save