From 1a119660ea9df2fad4d37e033999a5defcec53b1 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Tue, 25 Sep 2012 13:48:21 +0100 Subject: [PATCH] Display better messages on failing to open a file. 1. Usually the error messages from the :open() method are too long (except for crereader files) and won't be shown. So, I extract the first 30 bytes from the error message (if there is one) and show that. But if there is no error message then just display the generic "Error opening document ". Otherwise, as was currently the case, the error message is present but is too long and so we get absolutely nothing, not even a generic one. But in the Debug output we can show the entire error message as there is no restriction on the length. 2. Use showInfoMsgWithDelay() instead of InfoMessage:show() followed by util.sleep(). 3. Remove the dependency on keys.lua. This was needed when we were detecting emulation by comparing the physical value of some KEY_ but now we use util.isEmulated() so there is no need for it anymore. --- reader.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reader.lua b/reader.lua index d59cda25d..f8d8639d8 100755 --- a/reader.lua +++ b/reader.lua @@ -23,7 +23,6 @@ require "crereader" require "filechooser" require "settings" require "screen" -require "keys" require "commands" require "dialog" require "extentions" @@ -53,8 +52,12 @@ function openFile(filename) G_reader_settings:saveSetting("lastfile", filename) return reader:inputLoop() else - InfoMessage:show(err or "Error opening document.", 0) - util.sleep(2) + if err then + Debug("openFile(): "..err) + showInfoMsgWithDelay(err:sub(1,30), 2000, 1) + else + showInfoMsgWithDelay("Error opening document ", 2000, 1) + end end end return true -- on failed attempts, we signal to keep running