Implement granular decode error messages (#2)
New exceptions for specific decode failures: - InvalidMagicBytesError: wrong mode or not a Stegasoo image - ReedSolomonError: image too corrupted to recover - NoDataFoundError, ModeMismatchError: additional clarity Web UI now shows specific, actionable error messages: - "Try a different mode (LSB/DCT)" - "Image too corrupted, may have been re-saved" - "Wrong credentials - check reference photo..." 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,9 @@ from stegasoo import (
|
||||
CapacityError,
|
||||
DecryptionError,
|
||||
FilePayload,
|
||||
InvalidHeaderError,
|
||||
InvalidMagicBytesError,
|
||||
ReedSolomonError,
|
||||
StegasooError,
|
||||
export_rsa_key_pem,
|
||||
generate_credentials,
|
||||
@@ -1289,10 +1292,28 @@ def decode_page():
|
||||
has_qrcode_read=HAS_QRCODE_READ,
|
||||
)
|
||||
|
||||
except InvalidMagicBytesError:
|
||||
flash(
|
||||
"This doesn't appear to be a Stegasoo image. Try a different mode (LSB/DCT).",
|
||||
"warning",
|
||||
)
|
||||
return render_template("decode.html", has_qrcode_read=HAS_QRCODE_READ)
|
||||
except ReedSolomonError:
|
||||
flash(
|
||||
"Image too corrupted to decode. It may have been re-saved or compressed.",
|
||||
"error",
|
||||
)
|
||||
return render_template("decode.html", has_qrcode_read=HAS_QRCODE_READ)
|
||||
except InvalidHeaderError:
|
||||
flash(
|
||||
"Invalid or corrupted header. The image may have been modified.",
|
||||
"error",
|
||||
)
|
||||
return render_template("decode.html", has_qrcode_read=HAS_QRCODE_READ)
|
||||
except DecryptionError:
|
||||
flash(
|
||||
"Decryption failed. Check passphrase, PIN, RSA key, reference photo, and channel key.",
|
||||
"error",
|
||||
"Wrong credentials. Double-check your reference photo, passphrase, PIN, and channel key.",
|
||||
"warning",
|
||||
)
|
||||
return render_template("decode.html", has_qrcode_read=HAS_QRCODE_READ)
|
||||
except StegasooError as e:
|
||||
|
||||
Reference in New Issue
Block a user