diff --git a/EpcQrCodeJavaFxApp/src/main/kotlin/net/codinux/banking/epcqrcode/windows/main/MainWindow.kt b/EpcQrCodeJavaFxApp/src/main/kotlin/net/codinux/banking/epcqrcode/windows/main/MainWindow.kt index f7369c2..bb5a522 100644 --- a/EpcQrCodeJavaFxApp/src/main/kotlin/net/codinux/banking/epcqrcode/windows/main/MainWindow.kt +++ b/EpcQrCodeJavaFxApp/src/main/kotlin/net/codinux/banking/epcqrcode/windows/main/MainWindow.kt @@ -6,10 +6,16 @@ import tornadofx.* import java.io.ByteArrayInputStream import net.codinux.banking.epcqrcode.MppTest import net.codinux.banking.epcqrcode.QrCodeGenerator +import org.slf4j.LoggerFactory class MainWindow : View(FX.messages["application.title"]) { + companion object { + private val logger = LoggerFactory.getLogger(MainWindow::class.java) + } + + private val qrCodeGenerator = QrCodeGenerator() private val qrCode = SimpleObjectProperty(generateQrCode(MppTest().getTestEpcQrCodeContent())) @@ -21,9 +27,15 @@ class MainWindow : View(FX.messages["application.title"]) { private fun generateQrCode(informationToEncode: String): Image? { - val qrCodeBytes = qrCodeGenerator.generateQrCode(informationToEncode) + try { + val qrCodeBytes = qrCodeGenerator.generateQrCode(informationToEncode) - return Image(ByteArrayInputStream(qrCodeBytes)) + return Image(ByteArrayInputStream(qrCodeBytes)) + } catch (e: Exception) { + logger.error("Could not generate QR code for $informationToEncode", e) + } + + return null } } \ No newline at end of file