Implemented catching and logging exceptions
This commit is contained in:
parent
f88070181d
commit
1b6e5c363b
|
@ -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<Image>(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
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue