瀏覽代碼

Adds back RethrowErrorHandler

Nicolas Petton 11 年之前
父節點
當前提交
5ad863527b
共有 2 個文件被更改,包括 56 次插入1 次删除
  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
+! !
+