Add failure analyzer for incorrect interface name
This commit is contained in:
@@ -14,7 +14,6 @@ public class PcapFileNotFoundFailureAnalyzer extends AbstractFailureAnalyzer<Pca
|
||||
String description = "The file " + cause.getFile().getAbsolutePath() + " was not found";
|
||||
String existingFilesMessage;
|
||||
|
||||
|
||||
File[] existingFiles = cause.getDirectory().listFiles();
|
||||
|
||||
if (existingFiles == null) {
|
||||
@@ -26,7 +25,6 @@ public class PcapFileNotFoundFailureAnalyzer extends AbstractFailureAnalyzer<Pca
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (existingFiles.length == 0) {
|
||||
existingFilesMessage = "The pcaps directory is currently empty";
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package ru.serega6531.packmate.exception.analyzer;
|
||||
|
||||
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
import ru.serega6531.packmate.exception.PcapInterfaceNotFoundException;
|
||||
|
||||
public class PcapInterfaceNotFoundFailureAnalyzer extends AbstractFailureAnalyzer<PcapInterfaceNotFoundException> {
|
||||
@Override
|
||||
protected FailureAnalysis analyze(Throwable rootFailure, PcapInterfaceNotFoundException cause) {
|
||||
return new FailureAnalysis(
|
||||
"The interface \"" + cause.getRequestedInterface() + "\" was not found",
|
||||
"Check the interface name in the config. Existing interfaces are: " + cause.getExistingInterfaces(),
|
||||
cause
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user