Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

In this page you can find the example usage for java.lang Exception getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.panet.imeta.job.entry.validator.JobEntryValidatorUtils.java

public static void addExceptionRemark(CheckResultSourceInterface source, String propertyName,
        String validatorName, List<CheckResultInterface> remarks, Exception e) {
    String key = "messages.failed.unableToValidate"; //$NON-NLS-1$
    remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, ValidatorMessages.getString(key,
            propertyName, e.getClass().getSimpleName() + ": " + e.getLocalizedMessage()), source)); //$NON-NLS-1$
}

From source file:com.sugaronrest.ErrorResponse.java

/**
 * Gets formatted error response exception or SugarCRM error message
 *
 * @param exception    Exception from SugarCRM REST API calls or .NET error
 * @param errorContent Error returned from SugarCRM
 * @return ErrorResponse object//w w w  .j  a  v a 2  s  . c  om
 */
public static ErrorResponse format(Exception exception, String errorContent) {
    ErrorResponse errorResponse = new ErrorResponse();
    errorResponse.setName("An error has occurred!");
    errorResponse.setExceptionType(exception.getClass().getSimpleName());
    errorResponse.setNumber(HttpStatus.SC_BAD_REQUEST);
    errorResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST);
    if (!StringUtils.isNotBlank(errorContent)) {
        errorResponse.setMessage(exception.getMessage());
    } else {
        errorResponse.setMessage(errorContent);
    }

    errorResponse.setTrace(exception);
    return errorResponse;
}

From source file:com.sunchenbin.store.feilong.core.lang.reflect.FieldUtil.java

/**
 *  Field,?? Class?./*from www . java  2 s  . c  om*/
 *
 * @param clz
 *            clz
 * @param fieldName
 *            ??
 * @return  Field ,?? Class ?
 * @see java.lang.Class#getDeclaredField(String)
 * @see org.apache.commons.lang3.reflect.FieldUtils#getDeclaredField(Class, String)
 * @see org.apache.commons.lang3.reflect.FieldUtils#getDeclaredField(Class, String, boolean)
 */
public static Field getDeclaredField(Class<?> clz, String fieldName) {
    try {
        return clz.getDeclaredField(fieldName);
    } catch (Exception e) {
        LOGGER.error(e.getClass().getName(), e);
        throw new ReflectException(e);
    }
}

From source file:com.sunchenbin.store.feilong.core.lang.reflect.FieldUtil.java

/**
 * .// ww w.  j  a  v  a  2 s.  com
 *
 * @param owner
 *            the owner
 * @param fieldName
 *            
 * @param value
 *            
 * @see java.lang.Object#getClass()
 * @see java.lang.Class#getField(String)
 * @see java.lang.reflect.Field#set(Object, Object)
 * 
 * @see org.apache.commons.lang3.reflect.FieldUtils#writeField(Field, Object, Object, boolean)
 * @since 1.4.0
 */
public static void setFieldValue(Object owner, String fieldName, Object value) {
    try {
        Class<?> ownerClass = owner.getClass();
        Field field = ownerClass.getField(fieldName);
        field.set(ownerClass, value);
    } catch (Exception e) {
        LOGGER.error(e.getClass().getName(), e);
        throw new ReflectException(e);
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.payments.SIBSPaymentsDA.java

private static String getMessage(Exception ex) {
    String message = (ex.getMessage() == null) ? ex.getClass().getSimpleName() : ex.getMessage();
    return BundleUtil.getString(Bundle.MANAGER, message);
}

From source file:io.tilt.minka.utils.Defaulter.java

private static PropertyEditor edit(final Properties props, final Object configurable, final Field staticField,
        final Field instanceField) throws IllegalAccessException {

    staticField.setAccessible(true);/*from  ww  w . jav  a 2  s  .  co  m*/
    final String name = instanceField.getName();
    final String staticValue = staticField.get(configurable).toString();
    final Object propertyOrDefault = props.getProperty(name, System.getProperty(name, staticValue));
    final String objName = configurable.getClass().getSimpleName();
    final PropertyEditor editor = PropertyEditorManager.findEditor(instanceField.getType());
    final String setLog = "Defaulter: set <{}> field [{}] = '{}' from {} ";
    try {
        editor.setAsText(propertyOrDefault.toString());
        logger.info(setLog, objName, name, editor.getValue(),
                propertyOrDefault != staticValue ? " property " : staticField.getName());
    } catch (Exception e) {
        logger.error(
                "Defaulter: object <{}> field: {} does not accept property or static "
                        + "default value: {} (reason: {})",
                objName, name, propertyOrDefault, e.getClass().getSimpleName());
        try { // at this moment only prop. might've been failed
            editor.setAsText(staticValue);
            logger.info(setLog, objName, name, editor.getValue(), staticField.getName());
        } catch (Exception e2) {
            final StringBuilder sb = new StringBuilder().append("Defaulter: object <").append(objName)
                    .append("> field: ").append(name).append(" does not accept static default value: ")
                    .append(propertyOrDefault).append(" (reason: ").append(e.getClass().getSimpleName())
                    .append(")");
            throw new RuntimeException(sb.toString());
        }

    }

    return editor;
}

From source file:com.trk.aboutme.facebook.internal.Utility.java

public static void logd(String tag, Exception e) {
    if (BuildConfig.DEBUG && tag != null && e != null) {
        Log.d(tag, e.getClass().getSimpleName() + ": " + e.getMessage());
    }//from  w ww . j a v a 2  s.co m
}

From source file:com.feilong.tools.net.httpclient3.HttpClientUtil.java

/**
 * ?log.//from  w w  w  .  ja v  a 2  s.  co m
 * 
 * @param httpMethod
 *            the http method
 * @return the http method attribute map for log
 */
private static Map<String, Object> getHttpMethodRequestAttributeMapForLog(HttpMethod httpMethod) {
    Map<String, Object> map = new LinkedHashMap<String, Object>();
    try {
        map.put("httpMethod.getName()", httpMethod.getName());
        map.put("httpMethod.getURI()", httpMethod.getURI().toString());
        map.put("httpMethod.getPath()", httpMethod.getPath());
        map.put("httpMethod.getQueryString()", httpMethod.getQueryString());

        map.put("httpMethod.getRequestHeaders()", httpMethod.getRequestHeaders());

        map.put("httpMethod.getDoAuthentication()", httpMethod.getDoAuthentication());
        map.put("httpMethod.getFollowRedirects()", httpMethod.getFollowRedirects());
        map.put("httpMethod.getHostAuthState()", httpMethod.getHostAuthState().toString());

        // HttpMethodParams httpMethodParams = httpMethod.getParams();
        // map.put("httpMethod.getParams()", httpMethodParams);
        map.put("httpMethod.getProxyAuthState()", httpMethod.getProxyAuthState().toString());

    } catch (Exception e) {
        log.error(e.getClass().getName(), e);
    }
    return map;
}

From source file:tools.xor.util.ClassUtil.java

public static RuntimeException wrapRun(Exception e) {
    if (InvocationTargetException.class.isAssignableFrom(e.getClass())) {
        InvocationTargetException ite = (InvocationTargetException) e;
        Throwable cause = ite.getCause();
        if (cause != null && Exception.class.isAssignableFrom(cause.getClass()))
            e = (Exception) cause;
    }// w  w  w  .j av  a  2s.  com

    if (RuntimeException.class.isAssignableFrom(e.getClass()))
        return (RuntimeException) e;
    else
        return new RuntimeException(e);
}

From source file:com.googlecode.jsfFlex.shared.tasks.AbstractRunnerFactory.java

private static String errorMessage(String packageClass, Exception type) {
    StringBuilder errorMessage = new StringBuilder();

    errorMessage.append("While creating an instance of " + packageClass);
    errorMessage.append(type.getClass().getName());
    errorMessage.append(" Exception was thrown.");

    return errorMessage.toString();
}