Example usage for java.lang ArrayStoreException getMessage

List of usage examples for java.lang ArrayStoreException getMessage

Introduction

In this page you can find the example usage for java.lang ArrayStoreException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:ArrayMap.java

private static void put(Object array, Object element, int index) {
    try {/*  w  w  w.ja v a  2s .  com*/
        if (array instanceof Object[]) {
            try {
                ((Object[]) array)[index] = element;
            } catch (ArrayStoreException e) {
                throw new IllegalArgumentException(
                        e.getMessage() + ": " + (element == null ? "null" : element.getClass().getName())
                                + " into " + array.getClass().getName());
            }
        } else {
            try {
                Array.set(array, index, element);
            } catch (IllegalArgumentException e) {
                throw new IllegalArgumentException(
                        e.getMessage() + ": " + (element == null ? "null" : element.getClass().getName())
                                + " into " + array.getClass().getName(),
                        e);
            }
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new ArrayIndexOutOfBoundsException(index + " into " + Array.getLength(array));
    }
}