Skip to content

Commit b67908d

Browse files
committed
Better error report management
1 parent 7c6a07f commit b67908d

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/FAST-Python-Tools-Tests/FASTPythonImporterTest.class.st

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,22 @@ FASTPythonImporterTest >> importerClass [
187187
{ #category : 'running' }
188188
FASTPythonImporterTest >> parse: aString [
189189

190-
^ fast := self importer parse: aString withPlatformLineEndings
190+
^ fast := self importer
191+
errorReportBlock: [ :i | i errors ifNotEmpty: [ self fail: 'Errors happened during parsing. Errors: ' , i errors printString ] ];
192+
parse: aString withPlatformLineEndings
191193
]
192194

193195
{ #category : 'private' }
194196
FASTPythonImporterTest >> performTest [
195197
"If an error happens, dump the AST in the message text so that we can have an idea of what is the problem in the logs."
196198

197-
[ super performTest ]
199+
"[ super performTest ]
198200
on: Error
199201
do: [ :failure |
200202
fast ifNotNil: [ failure messageText: failure messageText , ' FASTDump: ' , (RBParser parseExpression: fast rootEntities anyOne dump) formattedCode ].
201-
failure pass ]
203+
failure pass ]"
204+
205+
super performTest
202206
]
203207

204208
{ #category : 'running' }

src/FAST-Python-Tools/FASTPythonImporter.class.st

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Class {
22
#name : 'FASTPythonImporter',
33
#superclass : 'Object',
44
#instVars : [
5-
'tsParser'
5+
'tsParser',
6+
'errorReportBlock'
67
],
78
#category : 'FAST-Python-Tools',
89
#package : 'FAST-Python-Tools'
@@ -103,6 +104,12 @@ FASTPythonImporter >> deleteTreeSitterParser [
103104
self tsParser delete
104105
]
105106

107+
{ #category : 'accessing' }
108+
FASTPythonImporter >> errorReportBlock: aBlock [
109+
110+
errorReportBlock := aBlock
111+
]
112+
106113
{ #category : 'as yet unclassified' }
107114
FASTPythonImporter >> initialiseTreeSitterParser [
108115

@@ -119,6 +126,7 @@ FASTPythonImporter >> parse: aString [
119126
tsTree := self tsParser parseString: aString.
120127
fastTree := TSFASTPythonImporter new
121128
originString: aString;
129+
in: [ :importer | errorReportBlock ifNotNil: [ importer errorReportBlock: errorReportBlock ] ];
122130
import: tsTree rootNode.
123131

124132
self deleteTreeSitterParser.

0 commit comments

Comments
 (0)