/**
 * Copyright (c) 2012-2013 André Bargull
 * Alle Rechte vorbehalten / All Rights Reserved.  Use is subject to license terms.
 *
 * <https://github.com/anba/es6draft>
 */
package com.github.anba.es6draft.runtime.internal;

import java.util.Objects;

import com.github.anba.es6draft.runtime.AbstractOperations;

/**
 * 
 */
@SuppressWarnings("serial")
public class ScriptException extends RuntimeException {
    private final Object value;

    public ScriptException(Object value) {
        // super(null, null, false, false);
        this.value = value;
    }

    public Object getValue() {
        return value;
    }

    @Override
    public String getMessage() {
        try {
            return AbstractOperations.ToFlatString(null, value);
        } catch (Throwable t) {
            return Objects.toString(value);
        }
    }
}

@@ -305,16 +305,74 @@
 rations;
+%0Aimport com.github.anba.es6draft.runtime.ExecutionContext;
 %0A%0A/**%0A *
@@ -893,11 +893,233 @@
  %7D%0A    %7D
+%0A%0A    public String getMessage(ExecutionContext cx) %7B%0A        try %7B%0A            return AbstractOperations.ToFlatString(cx, value);%0A        %7D catch (Throwable t) %7B%0A            return Objects.toString(value);%0A        %7D%0A    %7D
 %0A%7D%0A

Add getMessage() with execution-context to ScriptException to be able to get more faithful error messages