AI2 Component  (Version nb184)
RuntimeError.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2009-2011 Google, All Rights reserved
3 // Copyright 2011-2012 MIT, All rights reserved
4 // Released under the Apache License, Version 2.0
5 // http://www.apache.org/licenses/LICENSE-2.0
6 
7 package com.google.appinventor.components.runtime.errors;
8 
10 
15 @SimpleObject
16 public abstract class RuntimeError extends RuntimeException {
17 
21  protected RuntimeError() {
22  }
23 
29  protected RuntimeError(String message) {
30  super(message);
31  }
32 
40  public static RuntimeError convertToRuntimeError(Throwable throwable) {
41  if (throwable instanceof RuntimeError) {
42  return (RuntimeError) throwable;
43  }
44 
45  // Conversions of Java exceptions
46  if (throwable instanceof ArrayIndexOutOfBoundsException) {
47  return new ArrayIndexOutOfBoundsError();
48  }
49  if (throwable instanceof IllegalArgumentException) {
50  return new IllegalArgumentError();
51  }
52  if (throwable instanceof NullPointerException) {
53  return new UninitializedInstanceError();
54  }
55 
56  // TODO(user): needs to be implemented
57  throw new UnsupportedOperationException(throwable);
58  }
59 }
com.google.appinventor.components.runtime.errors.RuntimeError.RuntimeError
RuntimeError(String message)
Definition: RuntimeError.java:29
com.google.appinventor.components
com.google.appinventor.components.runtime.errors.ArrayIndexOutOfBoundsError
Definition: ArrayIndexOutOfBoundsError.java:17
com.google.appinventor.components.runtime.errors.IllegalArgumentError
Definition: IllegalArgumentError.java:17
com.google.appinventor.components.runtime.errors.RuntimeError.RuntimeError
RuntimeError()
Definition: RuntimeError.java:21
com.google.appinventor.components.runtime.errors.RuntimeError.convertToRuntimeError
static RuntimeError convertToRuntimeError(Throwable throwable)
Definition: RuntimeError.java:40
com.google.appinventor.components.annotations.SimpleObject
Definition: SimpleObject.java:23
com.google
com
com.google.appinventor.components.runtime.errors.UninitializedInstanceError
Definition: UninitializedInstanceError.java:17
com.google.appinventor.components.runtime.errors.RuntimeError
Definition: RuntimeError.java:16
com.google.appinventor.components.annotations
com.google.appinventor