mirror of
https://github.com/koreader/koreader
synced 2024-10-31 21:20:20 +00:00
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.
This commit is contained in:
parent
416c62ca61
commit
1a119660ea
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user