use of com.netflix.spinnaker.kork.exceptions.SpinnakerException in project kork by spinnaker.
the class ExceptionSummaryService method createTraceDetail.
private TraceDetail createTraceDetail(Throwable throwable, @Nullable ExceptionDetails exceptionDetails) {
TraceDetailBuilder detailBuilder = TraceDetail.builder().message(throwable.getMessage());
if (throwable instanceof SpinnakerException) {
SpinnakerException spinnakerException = (SpinnakerException) throwable;
detailBuilder.userMessage(exceptionMessageDecorator.decorate(throwable, spinnakerException.getUserMessage(), exceptionDetails)).retryable(spinnakerException.getRetryable());
}
if (throwable instanceof HasAdditionalAttributes) {
detailBuilder.additionalAttributes(((HasAdditionalAttributes) throwable).getAdditionalAttributes());
}
return detailBuilder.build();
}
use of com.netflix.spinnaker.kork.exceptions.SpinnakerException in project fiat by spinnaker.
the class RedisPermissionsRepository method getFromRedis.
private Optional<UserPermission> getFromRedis(@NonNull String id) {
try {
TimeoutContext timeoutContext = new TimeoutContext(String.format("getPermission for user: %s", id), clock, configProps.getRepository().getGetPermissionTimeout());
boolean userExists = UNRESTRICTED.equals(id) || redisRead(timeoutContext, c -> c.sismember(allUsersKey, SafeEncoder.encode(id)));
if (!userExists) {
log.debug("request for user {} not found in redis", id);
return Optional.empty();
}
UserPermission userPermission = new UserPermission().setId(id);
for (Resource r : resources) {
ResourceType resourceType = r.getResourceType();
Map<String, Resource> resourcePermissions = getUserResourceMapFromRedis(id, resourceType);
if (resourcePermissions != null && !resourcePermissions.isEmpty()) {
userPermission.addResources(resourcePermissions.values());
}
}
if (!UNRESTRICTED.equals(id)) {
userPermission.setAdmin(redisRead(timeoutContext, c -> c.sismember(adminKey, SafeEncoder.encode(id))));
userPermission.merge(getUnrestrictedUserPermission());
}
return Optional.of(userPermission);
} catch (Throwable t) {
String message = String.format("Storage exception reading %s entry.", id);
log.error(message, t);
if (t instanceof SpinnakerException) {
throw (SpinnakerException) t;
}
throw new PermissionReadException(message, t);
}
}
Aggregations