private static void forbidHeaderSpaceField(String fieldName, IpSpace fieldValue) { if (fieldValue != null && fieldValue != EmptyIpSpace.INSTANCE) { throw new BatfishException("unsupported HeaderSpace field " + fieldName); } }
Configuration config = hostConfig.getValue(); if (configurations.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { configurations.put(hostname, config); answerElement .getErrors() .put(_name, ((BatfishException) _failureCause).getBatfishStackTrace());
questionJson.put(parameterName, parameterObj); } catch (JSONException e1) { throw new BatfishException( "Failed to apply parameter: '" + parameterName throw new BatfishException("Failed to convert unmodified question string to JSON", e); } catch (BatfishException e) { _logger.errorf("Could not construct a question: %s\n", e.getMessage()); return false; BatfishObjectMapper.mapper().readValue(modifiedQuestionJson, Question.class); } catch (IOException e) { throw new BatfishException( "Modified question is no longer valid, likely due to invalid parameters", e);
containerName, testrigName, stackTrace); batfish.setTerminatingExceptionMessage( e.getClass().getName() + ": " + e.getMessage()); answer = new Answer(); answer.setStatus(AnswerStatus.FAILURE); answer.addAnswerElement(e.getBatfishStackTrace()); } catch (Throwable e) { String stackTrace = Throwables.getStackTraceAsString(e); answer.setStatus(AnswerStatus.FAILURE); answer.addAnswerElement( new BatfishException("Batfish job failed", e).getBatfishStackTrace()); } finally { try (ActiveSpan outputAnswerSpan =
throw new BatfishException("Failed to create directory: '" + testrigDir + "'"); new SnapshotMetadata(Instant.now(), parentSnapshotId), networkId, snapshotId); } catch (Exception e) { BatfishException metadataError = new BatfishException("Could not write testrigMetadata", e); try { CommonUtil.deleteDirectory(testrigDir); } catch (Exception inner) { metadataError.addSuppressed(inner);
} catch (BatfishException e) { return Response.status(Status.BAD_REQUEST) .entity(e.getMessage()) .type(MediaType.TEXT_PLAIN) .build();
answerElement .getErrors() .put(_filename, ((BatfishException) _failureCause).getBatfishStackTrace());
String hostname = _name; if (bgpTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { bgpTables.put(hostname, _bgpTable); answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace());
boolean processCommand(String[] words, @Nullable FileWriter outWriter) { Command command; try { command = Command.fromName(words[0]); } catch (BatfishException e) { _logger.errorf("Command failed: %s\n", e.getMessage()); return false; } List<String> options = getCommandOptions(words); List<String> parameters = getCommandParameters(words, options.size()); try (ActiveSpan span = GlobalTracer.get().buildSpan(command.commandName()).startActive()) { assert span != null; // make span not show up as unused. return processCommand(command, words, outWriter, options, parameters); } catch (Exception e) { e.printStackTrace(); return false; } }
public RoutingProtocol toRoutingProtocol() { switch (this) { case E1: return RoutingProtocol.OSPF_E1; case E2: return RoutingProtocol.OSPF_E2; default: throw new BatfishException("invalid ospf metric type"); } } }
String hostname = _name; if (routingTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { routingTables.put(hostname, _routingTable); answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace());
+ getFullText(ctx) + " : " + e.getMessage()); _currentInterfaces = ImmutableList.of(); return;
public String toInterfaceName() { if (_inverted) { // _warnings.redFlag("Inversion of interface matching is not supported."); throw new BatfishException("Unknown matchdata type"); } return (String) _matchData; } }
if (answerElement.getErrors().containsKey(hostConfig.getHostname())) { bfc = new BatfishException( failureMessage, answerElement.getErrors().get(hostConfig.getHostname()).getException()); answerElement.getErrors().put(hostConfig.getHostname(), bfc.getBatfishStackTrace()); } else { bfc = new BatfishException(failureMessage); if (_settings.getExitOnFirstError()) { throw bfc; } else { failureCauses.add(bfc); answerElement.getErrors().put(hostConfig.getHostname(), bfc.getBatfishStackTrace()); answerElement.getParseStatus().put(hostConfig.getIptablesFile(), ParseStatus.FAILED); throw new BatfishException("Could not get canonical path", e); new BatfishException( "Fatal exception due to at least one Iptables file is" + " not contained within the testrig");
+ getFullText(ctx) + " : " + e.getMessage()); _currentInterfaces = ImmutableList.of(); return;
private static DiffieHellmanGroup toDiffieHellmanGroup(String perfectForwardSecrecy) { switch (perfectForwardSecrecy) { case "group2": return DiffieHellmanGroup.GROUP2; default: throw new BatfishException( "No conversion to Diffie-Hellman group for string: \"" + perfectForwardSecrecy + "\""); } }
private void outputAnswer(Answer answer, boolean writeLog) { try { String answerString = BatfishObjectMapper.writePrettyString(answer) + '\n'; _logger.debug(answerString); @Nullable String logString = writeLog ? answerString : null; writeJsonAnswerWithLog(logString, answerString); } catch (Exception e) { BatfishException be = new BatfishException("Error in sending answer", e); try { Answer failureAnswer = Answer.failureAnswer(e.toString(), answer.getQuestion()); failureAnswer.addAnswerElement(be.getBatfishStackTrace()); String answerString = BatfishObjectMapper.writePrettyString(failureAnswer) + '\n'; _logger.error(answerString); @Nullable String logString = writeLog ? answerString : null; writeJsonAnswerWithLog(logString, answerString); } catch (Exception e1) { _logger.errorf( "Could not serialize failure answer. %s", Throwables.getStackTraceAsString(e1)); } throw be; } }
private static IpsecProtocol toIpsecProtocol(String ipsecProtocol) { switch (ipsecProtocol) { case "esp": return IpsecProtocol.ESP; default: throw new BatfishException( "No conversion to ipsec protocol for string: \"" + ipsecProtocol + "\""); } }
} catch (Exception e) { Answer answer = new Answer(); BatfishException exception = new BatfishException("Could not read question", e); answer.setStatus(AnswerStatus.FAILURE); answer.addAnswerElement(exception.getBatfishStackTrace()); return answer; } catch (Exception e) { Answer answer = new Answer(); BatfishException exception = new BatfishException("Could not parse question", e); answer.setStatus(AnswerStatus.FAILURE); answer.addAnswerElement(exception.getBatfishStackTrace()); return answer; exception = new BatfishException("Failed to answer question", e); answer.addAnswerElement(exception.getBatfishStackTrace());
public static OspfMetricType fromInteger(int i) { switch (i) { case 1: return E1; case 2: return E2; default: throw new BatfishException("invalid ospf metric type"); } }