use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class ExceptionMessagesProxy method invoke.
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final Class<?> type = type(method);
final String detailBase = detailBase(method);
final String detailKey = method.getName();
final ServiceCode serviceCode = serviceCode(method);
final Throwable cause = cause(args);
if (ServiceError.class.isAssignableFrom(type)) {
return contructServiceError(serviceCode, detailBase, detailKey, convertThrowableMessages(args));
}
Exception exception = contructException(type, serviceCode, cause, detailBase, detailKey, convertThrowableMessages(args));
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// removing the following 3 stack trace elements from the trackstrace:
// 0: Thread#getStackTrace
// 1: ExceptionMessagesProxy#invoke
// 2: com.sun.proxy.$ProxyXX#<methodName>
exception.setStackTrace(Arrays.copyOfRange(stackTrace, 3, stackTrace.length));
return exception;
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class ExceptionMessagesProxy method serviceCode.
/**
* Get the specified {@link ServiceCode} from the {@link DeclareServiceCode} annotation
*
* @param method
* @return
*/
private ServiceCode serviceCode(final Method method) {
final DeclareServiceCode declaredServiceCode = method.getAnnotation(DeclareServiceCode.class);
if (declaredServiceCode == null) {
throw new IllegalStateException("A service code must be provided via @DeclareServiceCode");
}
final ServiceCode serviceCode = declaredServiceCode.value();
return serviceCode;
}
Aggregations