[ OpalCompiler new evaluate: 'AnUnknownClass subclass: #Adaptor1Example
� � � � instanceVariableNames: ''customers accountID address name phoneNumber''
� � � � classVariableNames: ''''
� � � � poolDictionaries: ''''
� � � � category: ''Examples-Cookbook''' ] on: OCSemanticWarning do: [ :e | e halt ]
Here we catch the error, and you can handle it.�
Now it is not easily possible to resume the error, because you want a global instead and Opal expects a temp (there are way to resume but with very deep stack manipulation that I do not want to show to young pharoers present on this mailing list). So the best is to retry it. One solution is therefore:
[ OpalCompiler new evaluate: 'AnUnknownClass subclass: #Adaptor1Example
� � � � instanceVariableNames: ''customers accountID address phoneNumber''
� � � � classVariableNames: ''''
� � � � poolDictionaries: ''''
� � � � category: ''Examples-Cookbook''' ]�
on: OCSemanticWarning do: [ :e |�
Smalltalk at: e node name put: StubRootClass.
e retry ]�
with e node name answering #AnUnknownClass here.
Now you need to make sure that the exception block is executed for the case of a missing superclass and not something else or you will end up creating loads of globals.
The exception block should be something similar to:
�[ :e |�
� � � � e node name first isUppercase and: [ "some condition" ] ifTrue: [
Smalltalk at: e node name put: StubRootClass.
^ e retry ].
� � � � e pass ]�