|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk.internal; |
|
6 |
|
7 import org.chromium.sdk.ExceptionData; |
|
8 import org.chromium.sdk.JsObject; |
|
9 |
|
10 /** |
|
11 * An immutable implementation of the ExceptionData interface. |
|
12 */ |
|
13 public class ExceptionDataImpl implements ExceptionData { |
|
14 |
|
15 private final InternalContext context; |
|
16 private final String sourceText; |
|
17 private final ValueMirror mirror; |
|
18 private final String name; |
|
19 private final boolean isUncaught; |
|
20 private final String exceptionText; |
|
21 private JsObject cachedException; |
|
22 |
|
23 public ExceptionDataImpl(InternalContext context, ValueMirror mirror, String name, |
|
24 boolean isUncaught, String sourceText, String exceptionText) { |
|
25 this.context = context; |
|
26 this.mirror = mirror; |
|
27 this.name = name; |
|
28 this.isUncaught = isUncaught; |
|
29 this.sourceText = sourceText; |
|
30 this.exceptionText = exceptionText; |
|
31 } |
|
32 |
|
33 public JsObject getExceptionObject() { |
|
34 if (cachedException == null) { |
|
35 cachedException = new JsObjectImpl(context.getTopFrameImpl(), name, mirror); |
|
36 } |
|
37 return cachedException; |
|
38 } |
|
39 |
|
40 public String getSourceText() { |
|
41 return sourceText; |
|
42 } |
|
43 |
|
44 public boolean isUncaught() { |
|
45 return isUncaught; |
|
46 } |
|
47 |
|
48 public String getExceptionMessage() { |
|
49 return exceptionText; |
|
50 } |
|
51 |
|
52 } |