5061 log unlogged exceptions, fix copy paste and typo comment errors

This commit is contained in:
William Schaefer 2019-06-06 12:52:09 -04:00
parent 938d0826d7
commit 65bf9cc497
4 changed files with 12 additions and 12 deletions

View File

@ -71,7 +71,7 @@ public class BingTranslator implements TextTranslator {
} }
/** /**
* Converts an input test to the JSON format required by Bing Translator, * Converts an input text to the JSON format required by Bing Translator,
* posts it to Microsoft, and returns the JSON text response. * posts it to Microsoft, and returns the JSON text response.
* *
* @param string The input text to be translated. * @param string The input text to be translated.

View File

@ -22,7 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
/** /**
* Class to handle the settings associated with the GoogleTranslator * Class to handle the settings associated with the BingTranslator
*/ */
public final class BingTranslatorSettings { public final class BingTranslatorSettings {
@ -35,7 +35,7 @@ public final class BingTranslatorSettings {
private String targetLanguageCode; private String targetLanguageCode;
/** /**
* Construct a new GoogleTranslatorSettingsObject * Construct a new BingTranslatorSettings object
*/ */
BingTranslatorSettings() { BingTranslatorSettings() {
loadSettings(); loadSettings();

View File

@ -36,7 +36,7 @@ import org.apache.commons.lang3.StringUtils;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
/** /**
* Settings panel for the GoogleTranslator * Settings panel for the BingTranslator
*/ */
public class BingTranslatorSettingsPanel extends javax.swing.JPanel { public class BingTranslatorSettingsPanel extends javax.swing.JPanel {
@ -47,7 +47,7 @@ public class BingTranslatorSettingsPanel extends javax.swing.JPanel {
private String targetLanguageCode = ""; private String targetLanguageCode = "";
/** /**
* Creates new form GoogleTranslatorSettingsPanel * Creates new form BingTranslatorSettingsPanel
*/ */
public BingTranslatorSettingsPanel(String authenticationKey, String code) { public BingTranslatorSettingsPanel(String authenticationKey, String code) {
initComponents(); initComponents();
@ -254,16 +254,13 @@ public class BingTranslatorSettingsPanel extends javax.swing.JPanel {
private javax.swing.JLabel untranslatedLabel; private javax.swing.JLabel untranslatedLabel;
private javax.swing.JLabel warningLabel; private javax.swing.JLabel warningLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
/** /**
* Converts an input test to the JSON format required by Bing Translator, * Attempts to translate the text specified in the Untranslated field using
* posts it to Microsoft, and returns the JSON text response. * the settings currently specified but not necessarily saved
* *
* @param string The input text to be translated. * @return true if the translation was able to be performed, false otherwise
* *
* @return The translation response as a JSON string
*
* @throws IOException if the request could not be executed due to
* cancellation, a connectivity problem or timeout.
*/ */
private boolean testTranslationSetup() { private boolean testTranslationSetup() {
testResultValueLabel.setText(""); testResultValueLabel.setText("");
@ -291,6 +288,7 @@ public class BingTranslatorSettingsPanel extends javax.swing.JPanel {
testResultValueLabel.setText(translation0.get("text").getAsString()); testResultValueLabel.setText(translation0.get("text").getAsString());
return true; return true;
} catch (IOException | IllegalStateException | ClassCastException | NullPointerException | IndexOutOfBoundsException e) { } catch (IOException | IllegalStateException | ClassCastException | NullPointerException | IndexOutOfBoundsException e) {
logger.log(Level.WARNING, "Test of Bing Translator failed due to exception", ex);
return false; return false;
} }
} }

View File

@ -73,8 +73,10 @@ public final class GoogleTranslator implements TextTranslator {
address = InetAddress.getByName(host); address = InetAddress.getByName(host);
return address.isReachable(1500); return address.isReachable(1500);
} catch (UnknownHostException ex) { } catch (UnknownHostException ex) {
logger.log(Level.WARNING, "Unable to reach google.com due to unknown host", ex);
return false; return false;
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.WARNING, "Unable to reach google.com due IOException", ex);
return false; return false;
} }
} }