Log errors inside of ChangeEmail.getChangeDetail
Change-Id: I0b92126feeedb54e2761d7e90734a51442b5d9bf
This commit is contained in:
@@ -36,6 +36,9 @@ import com.google.gerrit.server.query.change.ChangeData;
|
|||||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -47,6 +50,8 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
/** Sends an email to one or more interested parties. */
|
/** Sends an email to one or more interested parties. */
|
||||||
public abstract class ChangeEmail extends OutgoingEmail {
|
public abstract class ChangeEmail extends OutgoingEmail {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ChangeEmail.class);
|
||||||
|
|
||||||
protected final Change change;
|
protected final Change change;
|
||||||
protected PatchSet patchSet;
|
protected PatchSet patchSet;
|
||||||
protected PatchSetInfo patchSetInfo;
|
protected PatchSetInfo patchSetInfo;
|
||||||
@@ -224,33 +229,38 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||||||
|
|
||||||
/** Create the change message and the affected file list. */
|
/** Create the change message and the affected file list. */
|
||||||
public String getChangeDetail() {
|
public String getChangeDetail() {
|
||||||
StringBuilder detail = new StringBuilder();
|
try {
|
||||||
|
StringBuilder detail = new StringBuilder();
|
||||||
|
|
||||||
if (patchSetInfo != null) {
|
if (patchSetInfo != null) {
|
||||||
detail.append(patchSetInfo.getMessage().trim() + "\n");
|
detail.append(patchSetInfo.getMessage().trim() + "\n");
|
||||||
} else {
|
} else {
|
||||||
detail.append(change.getSubject().trim() + "\n");
|
detail.append(change.getSubject().trim() + "\n");
|
||||||
}
|
|
||||||
|
|
||||||
if (patchSet != null) {
|
|
||||||
detail.append("---\n");
|
|
||||||
PatchList patchList = getPatchList();
|
|
||||||
for (PatchListEntry p : patchList.getPatches()) {
|
|
||||||
if (Patch.COMMIT_MSG.equals(p.getNewName())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
detail.append(p.getChangeType().getCode() + " " + p.getNewName() + "\n");
|
|
||||||
}
|
}
|
||||||
detail.append(MessageFormat.format("" //
|
|
||||||
+ "{0,choice,0#0 files|1#1 file|1<{0} files} changed, " //
|
if (patchSet != null) {
|
||||||
+ "{1,choice,0#0 insertions|1#1 insertion|1<{1} insertions}(+), " //
|
detail.append("---\n");
|
||||||
+ "{2,choice,0#0 deletions|1#1 deletion|1<{2} deletions}(-)" //
|
PatchList patchList = getPatchList();
|
||||||
+ "\n", patchList.getPatches().size() - 1, //
|
for (PatchListEntry p : patchList.getPatches()) {
|
||||||
patchList.getInsertions(), //
|
if (Patch.COMMIT_MSG.equals(p.getNewName())) {
|
||||||
patchList.getDeletions()));
|
continue;
|
||||||
detail.append("\n");
|
}
|
||||||
|
detail.append(p.getChangeType().getCode() + " " + p.getNewName() + "\n");
|
||||||
|
}
|
||||||
|
detail.append(MessageFormat.format("" //
|
||||||
|
+ "{0,choice,0#0 files|1#1 file|1<{0} files} changed, " //
|
||||||
|
+ "{1,choice,0#0 insertions|1#1 insertion|1<{1} insertions}(+), " //
|
||||||
|
+ "{2,choice,0#0 deletions|1#1 deletion|1<{2} deletions}(-)" //
|
||||||
|
+ "\n", patchList.getPatches().size() - 1, //
|
||||||
|
patchList.getInsertions(), //
|
||||||
|
patchList.getDeletions()));
|
||||||
|
detail.append("\n");
|
||||||
|
}
|
||||||
|
return detail.toString();
|
||||||
|
} catch (Exception err) {
|
||||||
|
log.warn("Cannot format change detail", err);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
return detail.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user