Skip to content

Commit

Permalink
Make sure we log the exception when there's a configuration error.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbriones committed Jan 26, 2012
1 parent a20b0ad commit 4c13a07
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/hudson/plugins/campfire/DescriptorImpl.java
Expand Up @@ -6,6 +6,9 @@
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;

import java.util.logging.Level;
import java.util.logging.Logger;

public class DescriptorImpl extends BuildStepDescriptor<Publisher> {
private boolean enabled = false;
private String subdomain;
Expand All @@ -15,6 +18,7 @@ public class DescriptorImpl extends BuildStepDescriptor<Publisher> {
private boolean ssl;
private boolean smartNotify;
private boolean sound;
private static final Logger LOGGER = Logger.getLogger(DescriptorImpl.class.getName());

public DescriptorImpl() {
super(CampfireNotifier.class);
Expand Down Expand Up @@ -69,7 +73,9 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData) throws For
try {
return new CampfireNotifier(subdomain, token, projectRoom, hudsonUrl, ssl, smartNotify, sound);
} catch (Exception e) {
throw new FormException("Failed to initialize campfire notifier - check your campfire notifier configuration settings: " + e.getMessage(), e, "");
String message = "Failed to initialize campfire notifier - check your campfire notifier configuration settings: " + e.getMessage();
LOGGER.log(Level.WARNING, message, e);
throw new FormException(message, e, "");
}
}

Expand All @@ -88,7 +94,9 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti
try {
new CampfireNotifier(subdomain, token, room, hudsonUrl, ssl, smartNotify, sound);
} catch (Exception e) {
throw new FormException("Failed to initialize campfire notifier - check your global campfire notifier configuration settings: " + e.getMessage(), e, "");
String message = "Failed to initialize campfire notifier - check your global campfire notifier configuration settings: " + e.getMessage();
LOGGER.log(Level.WARNING, message, e);
throw new FormException(message, e, "");
}
save();
return super.configure(req, json);
Expand Down

0 comments on commit 4c13a07

Please sign in to comment.