Slightly friendlier, more generic error message when no barcode is found

git-svn-id: https://zxing.googlecode.com/svn/trunk@149 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-01-22 18:59:47 +00:00
parent a9b85ab5b3
commit 1ec82dd376
2 changed files with 9 additions and 1 deletions

View file

@ -19,6 +19,7 @@ package com.google.zxing.client.j2me;
import com.google.zxing.MonochromeBitmapSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Reader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import javax.microedition.lcdui.Image;
@ -56,6 +57,9 @@ final class SnapshotThread extends Thread {
Reader reader = new MultiFormatReader();
Result result = reader.decode(source);
zXingMIDlet.handleDecodedText(result.getText());
} catch (ReaderException re) {
// Show a friendlier message on a mere failure to read the barcode
zXingMIDlet.showError("No barcode was detected in this image. Try again.");
} catch (Throwable t) {
zXingMIDlet.showError(t);
} finally {

View file

@ -143,7 +143,11 @@ public final class ZXingMIDlet extends MIDlet {
}
void showError(Throwable t) {
showAlert(new Alert("Error", t.getMessage(), null, AlertType.ERROR));
showError(t.getMessage());
}
void showError(String message) {
showAlert(new Alert("Error", message, null, AlertType.ERROR));
}
private void showAlert(Alert alert) {