|
1 | 1 | package org.jabref.gui.preview;
|
2 | 2 |
|
3 | 3 | import java.io.IOException;
|
| 4 | +import java.io.PrintWriter; |
| 5 | +import java.io.StringWriter; |
4 | 6 | import java.net.MalformedURLException;
|
5 | 7 | import java.util.Objects;
|
6 | 8 | import java.util.Optional;
|
@@ -257,13 +259,22 @@ private void update() {
|
257 | 259 |
|
258 | 260 | Number.serialExportNumber = 1; // Set entry number in case that is included in the preview layout.
|
259 | 261 |
|
| 262 | + final BibEntry theEntry = entry.get(); |
260 | 263 | BackgroundTask
|
261 |
| - .wrap(() -> layout.generatePreview(entry.get(), database)) |
| 264 | + .wrap(() -> layout.generatePreview(theEntry, database)) |
262 | 265 | .onRunning(() -> setPreviewText("<i>" + Localization.lang("Processing %0", Localization.lang("Citation Style")) + ": " + layout.getDisplayName() + " ..." + "</i>"))
|
263 | 266 | .onSuccess(this::setPreviewText)
|
264 | 267 | .onFailure(exception -> {
|
265 | 268 | LOGGER.error("Error while generating citation style", exception);
|
266 |
| - setPreviewText(Localization.lang("Error while generating citation style")); |
| 269 | + |
| 270 | + // Convert stack trace to a string |
| 271 | + StringWriter stringWriter = new StringWriter(); |
| 272 | + PrintWriter printWriter = new PrintWriter(stringWriter); |
| 273 | + exception.printStackTrace(printWriter); |
| 274 | + String stackTraceString = stringWriter.toString(); |
| 275 | + |
| 276 | + // Set the preview text with the localized error message and the stack trace |
| 277 | + setPreviewText(Localization.lang("Error while generating citation style") + "\n\n" + exception.getLocalizedMessage() + "\n\nBibTeX (internal):\n" + theEntry + "\n\nStack Trace:\n" + stackTraceString); |
267 | 278 | })
|
268 | 279 | .executeWith(taskExecutor);
|
269 | 280 | }
|
|
0 commit comments