Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lets AS2 exceptions be handled

  • Loading branch information...
commit d8f85a151209ee0997abce3584d6f37f457ccf95 1 parent 1ad23e0
@yurydelendik yurydelendik authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 src/avm1/interpreter.js
View
13 src/avm1/interpreter.js
@@ -43,6 +43,9 @@ AS2Context.prototype = {
return this.resolveTarget(this.globals['_level' + level]);
}
};
+function AS2Error(error) {
+ this.error = error;
+}
function as2GetType(v) {
if (v === null)
@@ -369,10 +372,12 @@ function interpretActions(actionsData, scopeContainer,
} catch (e) {
if (!catchBlockFlag)
throw e;
+ if (!(e instanceof AS2Error))
+ throw e;
if (typeof catchTarget === 'string')
- scope[catchTarget] = e;
+ scope[catchTarget] = e.error;
else
- registers[catchTarget] = e;
+ registers[catchTarget] = e.error;
interpretActions(catchBlock, scopeContainer, constantPool, registers);
} finally {
if (finallyBlockFlag)
@@ -1058,7 +1063,7 @@ function interpretActions(actionsData, scopeContainer,
break;
case 0x2A: // ActionThrow
var obj = stack.pop();
- throw obj;
+ throw new AS2Error(obj);
// Not documented by the spec
case 0x2D: // ActionFSCommand2
var numArgs = stack.pop();
@@ -1084,6 +1089,8 @@ function interpretActions(actionsData, scopeContainer,
} catch (e) {
if (!isAVM1ErrorsIgnored)
throw e;
+ if (e instanceof AS2Error)
+ throw e;
stream.position = nextPosition;
if (!recoveringFromError) {
console.error('AVM1 error: ' + e);
Please sign in to comment.
Something went wrong with that request. Please try again.