/*
 * Copyright (c) OSGi Alliance (2016). All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.osgi.util.converter;

import java.lang.reflect.Type;

import org.osgi.annotation.versioning.ConsumerType;

/**
 * An functional interface with a single convert method that is passed the
 * original object and the target type.
 *
 * @param <F> Type parameter for the source object.
 * @param <T> Type parameter for the converted object.
 * @author $Id$
 */
@ConsumerType
@FunctionalInterface
public interface ConvertFunction<F, T> {
	/**
	 * Convert the object into the target type.
	 *
	 * @param obj The object to be converted. This object will never be
	 *            {@code null} as the convert function will not be invoked for
	 *            null values.
	 * @param targetType The target type.
	 * @param root The root object, if this obj was embedded in a root object.
	 *            Otherwise {@code null}.
	 * @param keyPath If the object is embedded in a root object, the path of
	 *            keys that reach this object. Otherwise {@code null}.
	 * @return The conversion result or {@code null} to indicate that the
	 *         convert function cannot handle this conversion. In this case the
	 *         next matching rule or adapter will be given a opportunity to
	 *         convert.
	 * @throws Exception
	 */
	T convert(F obj, Type targetType, Object root, Object[] keyPath)
			throws Exception;
}

@@ -1942,11 +1942,1037 @@
 ception;
+%0A%0A%09/**%0A%09 * Override the default error handling mechanism. Whenever a converter%0A%09 * throws a Conversion Exception, this can be overridden with either another%0A%09 * runtime exception or an actual value.%0A%09 *%0A%09 * @param obj The object to be converted. This object will never be%0A%09 *            %7B@code null%7D as the convert function will not be invoked for%0A%09 *            null values.%0A%09 * @param targetType The target type.%0A%09 * @param root The root object, if this obj was embedded in a root object.%0A%09 *            Otherwise %7B@code null%7D.%0A%09 * @param keyPath If the object is embedded in a root object, the path of%0A%09 *            keys that reach this object. Otherwise %7B@code null%7D.%0A%09 * @return A value to use in case of an error. This method can return%0A%09 *         %7B@code null%7D to indicate that it cannot handle the error.%0A%09 * @throws RuntimeException Another Runtime Exception may also be thrown by%0A%09 *             this handler.%0A%09 */%0A%09default T handleError(F obj, Type targetType, Object root,%0A%09%09%09Object%5B%5D keyPath) %7B%0A%09%09return null;%0A%09%7D
 %0A%7D%0A

Add handleError() to ConvertFunction