Prechádzať zdrojové kódy

Adds back RethrowErrorHandler

Nicolas Petton 10 rokov pred
rodič
commit
5ad863527b
2 zmenil súbory, kde vykonal 56 pridanie a 1 odobranie
  1. 37 1
      js/Compiler-Exceptions.js
  2. 19 0
      st/Compiler-Exceptions.st

+ 37 - 1
js/Compiler-Exceptions.js

@@ -1,4 +1,4 @@
-define("amber_core/Compiler-Exceptions", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Exceptions"], function(smalltalk,nil,_st, globals){
+define("amber_core/Compiler-Exceptions", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st, globals){
 smalltalk.addPackage('Compiler-Exceptions');
 smalltalk.packages["Compiler-Exceptions"].transport = {"type":"amd","amdNamespace":"amber_core"};
 
@@ -181,4 +181,40 @@ referencedClasses: []
 globals.UnknownVariableError);
 
 
+
+smalltalk.addClass('RethrowErrorHandler', globals.Object, [], 'Compiler-Exceptions');
+globals.RethrowErrorHandler.comment="This class is used in the commandline version of the compiler.\x0aIt uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.\x0aAs a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.";
+smalltalk.addMethod(
+smalltalk.method({
+selector: "basicSignal:",
+protocol: 'error handling',
+fn: function (anError){
+var self=this;
+throw anError;
+return self},
+args: ["anError"],
+source: "basicSignal: anError\x0a        <throw anError>",
+messageSends: [],
+referencedClasses: []
+}),
+globals.RethrowErrorHandler);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "handleError:",
+protocol: 'error handling',
+fn: function (anError){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+globals.RethrowErrorHandler.superclass.fn.prototype._handleError_.apply(_st(self), [anError]);
+self._basicSignal_(anError);
+return self}, function($ctx1) {$ctx1.fill(self,"handleError:",{anError:anError},globals.RethrowErrorHandler)})},
+args: ["anError"],
+source: "handleError: anError\x0a        super handleError: anError.\x0a        self basicSignal: anError",
+messageSends: ["handleError:", "basicSignal:"],
+referencedClasses: []
+}),
+globals.RethrowErrorHandler);
+
+
 });

+ 19 - 0
st/Compiler-Exceptions.st

@@ -89,3 +89,22 @@ variableName: aString
 	variableName := aString
 ! !
 
+Object subclass: #RethrowErrorHandler
+	instanceVariableNames: ''
+	package: 'Compiler-Exceptions'!
+!RethrowErrorHandler commentStamp!
+This class is used in the commandline version of the compiler.
+It uses the handleError: message of ErrorHandler for printing the stacktrace and throws the error again as JS exception.
+As a result Smalltalk errors are not swallowd by the Amber runtime and compilation can be aborted.!
+
+!RethrowErrorHandler methodsFor: 'error handling'!
+
+basicSignal: anError
+        <throw anError>
+!
+
+handleError: anError
+        super handleError: anError.
+        self basicSignal: anError
+! !
+