Hi,
I am having trouble making the compiler not be interactive when it encounters a syntax error. To reproduce the problem I attach here an .st file that has a funny character in the method name. If I file this in, like: ‘AAA.st’ asFileReference fileIn. I get a Syntax Error dialog. I would like to avoid that. After diving in, I noticed that I can tell the requestor of the CodeImporter to not be interactive, but that does not seem to have an effect: 'AAA.st' asFileReference readStreamDo: [ :s | importer := CodeImporter fileStream: s. importer requestor interactive: false. importer evaluateDeclarations ] I also tried to play on the end of the SyntaxErrorDebugger, and replace it with something that logs the exception, but I was not successful because that one is expected to return a string that can be compiled. Can anyone point me in the right direction? Cheers, Doru -- www.tudorgirba.com www.feenk.com "Every now and then stop and ask yourself if the war you're fighting is the right one." AAA.st (252 bytes) Download Attachment |
Catching the Notification stops it from popping up the syntaxErrorDebugger. 'AAA.st' asFileReference readStreamDo: [ :s | importer := CodeImporter fileStream: s.
[ importer evaluateDeclarations ] on: SyntaxErrorNotification do: [ :e | …]
]. From: Pharo-dev [mailto:[hidden email]]
On Behalf Of Tudor Girba Hi, I am having trouble making the compiler not be interactive when it encounters a syntax error. To reproduce the problem I attach here an .st file that has a funny character in the method name. If I file this in, like: ‘AAA.st’ asFileReference fileIn. I get a Syntax Error dialog. I would like to avoid that. After diving in, I noticed that I can tell the requestor of the CodeImporter to not be interactive, but that does not seem to have an effect: 'AAA.st' asFileReference readStreamDo: [ :s | importer := CodeImporter fileStream: s. I also tried to play on the end of the SyntaxErrorDebugger, and replace it with something that logs the exception, but I was not successful because that one is expected to return a string that can be compiled. Can anyone point me in the right direction? Cheers, Doru -- |
Hi,
Thanks! I tried before with catching Error, but of course SyntaxErrorNotification is a Notification :). This means I am tired and I should go to sleep. Thanks again for unlocking me. Cheers, Doru > On May 21, 2016, at 11:30 PM, Henrik Nergaard <[hidden email]> wrote: > > Catching the Notification stops it from popping up the syntaxErrorDebugger. > > 'AAA.st' asFileReference readStreamDo: [ :s | > importer := CodeImporter fileStream: s. > > [ importer evaluateDeclarations ] on: SyntaxErrorNotification do: [ :e | …] > > ]. > > From: Pharo-dev [mailto:[hidden email]] On Behalf Of Tudor Girba > Sent: Saturday, May 21, 2016 11:25 PM > To: Pharo Development List <[hidden email]> > Subject: [Pharo-dev] how to swallow a syntax error? > > Hi, > > I am having trouble making the compiler not be interactive when it encounters a syntax error. > > To reproduce the problem I attach here an .st file that has a funny character in the method name. If I file this in, like: > ‘AAA.st’ asFileReference fileIn. > > I get a Syntax Error dialog. I would like to avoid that. > > After diving in, I noticed that I can tell the requestor of the CodeImporter to not be interactive, but that does not seem to have an effect: > 'AAA.st' asFileReference readStreamDo: [ :s | > importer := CodeImporter fileStream: s. > importer requestor interactive: false. > importer evaluateDeclarations ] > > I also tried to play on the end of the SyntaxErrorDebugger, and replace it with something that logs the exception, but I was not successful because that one is expected to return a string that can be compiled. > > Can anyone point me in the right direction? > > Cheers, > Doru > > -- > www.tudorgirba.com > www.feenk.com > > "Every now and then stop and ask yourself if the war you're fighting is the right one." > -- www.tudorgirba.com www.feenk.com "Don't give to get. Just give." |
Free forum by Nabble | Edit this page |