# HG changeset patch # User David Barts # Date 1595274967 25200 # Node ID 2bb46da746673c048ce76f7bab75a108ad275e53 # Parent fad32eda667fa1b32ba5da6a998a16ebaf136ea1 Detect unsupported file types on input. diff -r fad32eda667f -r 2bb46da74667 src/name/blackcap/imageprep/Misc.kt --- a/src/name/blackcap/imageprep/Misc.kt Sun Jul 19 13:49:23 2020 -0700 +++ b/src/name/blackcap/imageprep/Misc.kt Mon Jul 20 12:56:07 2020 -0700 @@ -233,6 +233,14 @@ border = BorderFactory.createCompoundBorder(b, border) } +/** + * Display an error dialog pertaining to an IOException. + * + * @param parent Parent component for this dialog + * @param file java.io.File object associated with this error + * @param op Operation that failed (e.g. "read", "write", etc.) + * @param e An IOException + */ fun ioExceptionDialog(parent: Component, file: File, op: String, e: IOException) { val msg = e.message val fileName = file.getName() diff -r fad32eda667f -r 2bb46da74667 src/name/blackcap/imageprep/RotateDialog.kt --- a/src/name/blackcap/imageprep/RotateDialog.kt Sun Jul 19 13:49:23 2020 -0700 +++ b/src/name/blackcap/imageprep/RotateDialog.kt Mon Jul 20 12:56:07 2020 -0700 @@ -146,6 +146,8 @@ inBackground { try { val imageIn = ImageIO.read(input) /* IOException */ + if (imageIn == null) + throw IOException("Unsupported file type.") val ratio = Settings.maxDimension.toDouble() / max(imageIn.width, imageIn.height).toDouble() if (ratio >= 1.0) { Pair(null, null)