I'm thinking of adding error and progress reporting.
Currently, parse errors cause acorn to throw a SyntaxError which is being checked, logged and then thrown again towards higher layers.
The call stack is either
ScanCtrl -> ScanService -> ScanWorker -> ScanJS.scan
Or
index.js (nodejs) -> ScanJS.scan
I could continue throwing things up and down the stack, but I don't think that this is the correct way to handle this. Instead I would consider catching these SyntaxErrors in ScanJS.scan() itself and return them as part of the scanresults.
The current return value of ScanJS.scan() is an array of result objects (with rule,file,line) attributes. My question is, how should we integrate the error reporting and what should ScanJS.scan() return.
Suggestion 1:
An array of result and error objects. Result objects like before, (with rule,file,line attributes) and Error objects with (file, line, error).
Suggestion 2
An array of result objects and an array of errors, i.e.
return [scanresults, scanerrors].
I have taken a stab at this in this branch, see out the diff
Having written this up, I think I'd lean towards the first suggestions, but am open to other ideas :)
I'm thinking of adding error and progress reporting. Currently, parse errors cause acorn to throw a
SyntaxError
which is being checked, logged and then thrown again towards higher layers.The call stack is either
I could continue throwing things up and down the stack, but I don't think that this is the correct way to handle this. Instead I would consider catching these SyntaxErrors in ScanJS.scan() itself and return them as part of the scanresults.
The current return value of ScanJS.scan() is an array of result objects (with rule,file,line) attributes. My question is, how should we integrate the error reporting and what should ScanJS.scan() return.
Suggestion 1:
An array of result and error objects. Result objects like before, (with rule,file,line attributes) and Error objects with (file, line, error).
Suggestion 2
An array of result objects and an array of errors, i.e.
return [scanresults, scanerrors]
. I have taken a stab at this in this branch, see out the diffHaving written this up, I think I'd lean towards the first suggestions, but am open to other ideas :)