VSG would lockup if an error was encountered during classification. 1) Exception added to print_error_message to report classification errors. 2) Exception is caught in apply_rules.py and handled so it does not lock up the multiprocessing pool.
This commit is contained in:
parent
6cc3e7459b
commit
69efd19087
|
|
@ -6,6 +6,8 @@ from . import rule_list
|
|||
from . import utils
|
||||
from . import vhdlFile
|
||||
|
||||
from .exceptions import ClassifyError
|
||||
|
||||
|
||||
def create_backup_file(sFileName):
|
||||
'''Copies existing file and adds .bak to the end.'''
|
||||
|
|
@ -57,7 +59,17 @@ def apply_rules(commandLineArguments, oConfig, tIndexFileName):
|
|||
iIndex, sFileName = tIndexFileName
|
||||
dJsonEntry = {}
|
||||
lFileContent, eError = vhdlFile.utils.read_vhdlfile(sFileName)
|
||||
oVhdlFile = vhdlFile.vhdlFile(lFileContent, sFileName, eError)
|
||||
try:
|
||||
oVhdlFile = vhdlFile.vhdlFile(lFileContent, sFileName, eError)
|
||||
except ClassifyError as e:
|
||||
fExitStatus = True
|
||||
testCase = None
|
||||
dJsonEntry["file_path"] = sFileName
|
||||
dJsonEntry["violations"] = []
|
||||
sOutputStd = ''
|
||||
sOutputErr = e.message
|
||||
return fExitStatus, testCase, dJsonEntry, sOutputStd, sOutputErr
|
||||
|
||||
oVhdlFile.set_indent_map(dIndent)
|
||||
try:
|
||||
oRules = rule_list.rule_list(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
class ClassifyError(Exception):
|
||||
'''
|
||||
Exception raised for errors when classifying VHDL Files.
|
||||
'''
|
||||
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
return self.message
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
import sys
|
||||
|
||||
from vsg import exceptions
|
||||
from vsg import parser
|
||||
|
||||
|
||||
|
|
@ -399,10 +402,16 @@ def print_error_message(sToken, token, iToken, lObjects):
|
|||
iLine = calculate_line_number(iToken, lObjects)
|
||||
iColumn = calculate_column(iToken, lObjects)
|
||||
sModuleName = extract_module_name(token)
|
||||
print(f'Error: Unexpected token detected while parsing {sModuleName} @ Line {iLine}, Column {iColumn} in file {lObjects[0].get_filename()}')
|
||||
print(f' Expecting : {sToken}')
|
||||
print(f' Found : {sFoundToken}')
|
||||
exit()
|
||||
|
||||
sErrorMesasge = '\n'
|
||||
sErrorMessage += f'Error: Unexpected token detected while parsing {sModuleName} @ Line {iLine}, Column {iColumn} in file {lObjects[0].get_filename()}'
|
||||
sErrorMesasge += '\n'
|
||||
sErrorMessage += f' Expecting : {sToken}'
|
||||
sErrorMesasge += '\n'
|
||||
sErrorMessage += f' Found : {sFoundToken}'
|
||||
sErrorMesasge += '\n'
|
||||
|
||||
raise exceptions.ClassifyError(sErrorMessage)
|
||||
|
||||
|
||||
def extract_module_name(token):
|
||||
|
|
|
|||
Loading…
Reference in New Issue