jetbrains.buildServer.util.ExceptionUtil Java Examples
The following examples show how to use
jetbrains.buildServer.util.ExceptionUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TelegramSettingsController.java From teamcity-telegram-plugin with Apache License 2.0 | 5 votes |
private String testSettings(@NotNull TelegramSettings settings) { try { BotInfo info = botManager.requestDescription(settings); if (info == null) { return "Can't find data about bot with requested token"; } return "bot name: " + info.getName() + "\n" + "bot username: " + info.getUsername(); } catch (Exception ex) { LOG.info("Can't send test message to Telegram: ", ex); return "Can't send test message to Telegram:\n" + ExceptionUtil.getDisplayMessage(ex); } }
Example #2
Source File: S3Util.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 5 votes |
@Nullable private static String extractCorrectedRegion(@NotNull final Throwable e) { @Nullable final AmazonS3Exception awsException = e instanceof AmazonS3Exception ? (AmazonS3Exception)e : ExceptionUtil.getCause(e, AmazonS3Exception.class); if (awsException != null && TeamCityProperties.getBooleanOrTrue("teamcity.internal.storage.s3.autoCorrectRegion") && awsException.getAdditionalDetails() != null) { final String correctRegion = awsException.getAdditionalDetails().get("Region"); if (correctRegion != null) { return correctRegion; } else { return awsException.getAdditionalDetails().get("x-amz-bucket-region"); } } else { return null; } }
Example #3
Source File: RetrierExponentialDelay.java From teamcity-s3-artifact-storage-plugin with Apache License 2.0 | 5 votes |
@Override public <T> void onFailure(@NotNull final Callable<T> callable, final int retry, @NotNull final Exception e) { if (myDelay > 0) { try { Thread.sleep(myDelay * (retry + 1)); } catch (InterruptedException ex) { ExceptionUtil.rethrowAsRuntimeException(e); } } }
Example #4
Source File: KubeCloudImageImpl.java From teamcity-kubernetes-plugin with Apache License 2.0 | 4 votes |
KubeCloudImageImpl(@NotNull final KubeCloudImageData kubeCloudImageData, @NotNull final KubeApiConnector apiConnector) { myImageData = kubeCloudImageData; final String templateContent = myImageData.getCustomPodTemplateContent(); if (StringUtil.isEmpty(templateContent)){ myPodTemplate = null; myPVCTemplate = null; } else if (templateContent.contains("\n---\n")){ final String processedContent; final String placeholderReplacement = "__INSTANCE__ID__"; if (templateContent.contains("%instance.id%")){ processedContent = templateContent.replaceAll("%instance.id%", placeholderReplacement); } else { processedContent = templateContent; } YAMLFactory factory = new YAMLFactory(); ObjectMapper mapper = new ObjectMapper(); final AtomicReference<String> podTemplateRef = new AtomicReference<>(); final AtomicReference<String> pvcTemplateRef = new AtomicReference<>(); try { YAMLParser parser = factory.createParser(processedContent); List<ObjectNode> list = mapper.readValues(parser, ObjectNode.class).readAll(); list.forEach(node->{ if (node.get("kind") != null && "Pod".equals(node.get("kind").textValue())){ if (podTemplateRef.get() != null){ throw new RuntimeException("More than one Pod template is specified for image " + myImageData.getAgentNamePrefix()); } podTemplateRef.set(node.toString().replaceAll(placeholderReplacement, "%instance.id%")); } else if (node.get("kind") != null && "PersistentVolumeClaim".equals(node.get("kind").textValue())){ if (pvcTemplateRef.get() != null){ throw new RuntimeException("More than one PVC template is specified for image " + myImageData.getAgentNamePrefix()); } pvcTemplateRef.set(node.toString().replaceAll(placeholderReplacement, "%instance.id%")); } else{ throw new RuntimeException("Unknown yaml template is specified for image " + myImageData.getAgentNamePrefix()); } }); } catch (IOException e) { ExceptionUtil.rethrowAsRuntimeException(e); } myPodTemplate = podTemplateRef.get(); myPVCTemplate = pvcTemplateRef.get(); } else { myPodTemplate = templateContent; myPVCTemplate = null; } myApiConnector = apiConnector; }