1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.tradefed.config; 17 18 import com.android.tradefed.sandbox.SandboxConfigurationException; 19 20 import java.util.HashMap; 21 import java.util.Map; 22 23 /** {@link ConfigurationException} for when the class of an object is not found. */ 24 public class ClassNotFoundConfigurationException extends ConfigurationException { 25 26 private static final long serialVersionUID = 7742154448569011969L; 27 private Map<String, String> mRejectedObjects; 28 29 /** 30 * Creates a {@link SandboxConfigurationException}. 31 * 32 * @param msg a meaningful error message 33 */ ClassNotFoundConfigurationException(String msg)34 public ClassNotFoundConfigurationException(String msg) { 35 super(msg); 36 } 37 38 /** 39 * Creates a {@link SandboxConfigurationException}. 40 * 41 * @param msg a meaningful error message 42 * @param cause the {@link Throwable} that represents the original cause of the error 43 * @param className the class of the object that was not found 44 * @param objectType the Tradefed object type of the object that was not found 45 */ ClassNotFoundConfigurationException( String msg, Throwable cause, String className, String objectType)46 public ClassNotFoundConfigurationException( 47 String msg, Throwable cause, String className, String objectType) { 48 super(msg, cause); 49 mRejectedObjects = new HashMap<>(); 50 mRejectedObjects.put(className, objectType); 51 } 52 53 /** 54 * Creates a {@link SandboxConfigurationException}. 55 * 56 * @param msg a meaningful error message 57 * @param cause the {@link Throwable} that represents the original cause of the error 58 * @param rejectedObjects The map of objects that failed loading. 59 */ ClassNotFoundConfigurationException( String msg, Throwable cause, Map<String, String> rejectedObjects)60 public ClassNotFoundConfigurationException( 61 String msg, Throwable cause, Map<String, String> rejectedObjects) { 62 super(msg, cause); 63 mRejectedObjects = rejectedObjects; 64 } 65 66 /** Returns the map of object class that was rejected. */ getRejectedObjects()67 public Map<String, String> getRejectedObjects() { 68 return mRejectedObjects; 69 } 70 } 71