From 27dc097981e82f93ee8d82df491041ea426d44ca Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 25 Sep 2017 13:55:40 +0300 Subject: [PATCH] catch editable load exception --- src/dlangui/core/editable.d | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dlangui/core/editable.d b/src/dlangui/core/editable.d index d64a8a2d..ed41d5cf 100644 --- a/src/dlangui/core/editable.d +++ b/src/dlangui/core/editable.d @@ -1423,14 +1423,22 @@ class EditableContent { /// load content from file bool load(string filename) { clear(); + if (!filename.exists || !filename.isFile) { + Log.e("Editable.load: File not found ", filename); + return false; + } try { InputStream f; f = new FileInputStream(filename); scope(exit) { f.close(); } bool res = load(f, filename); return res; + } catch (ErrnoException e) { + Log.e("Editable.load: Exception while trying to read file ", filename, " ", e.toString); + clear(); + return false; } catch (Exception e) { - Log.e("Exception while trying to read file ", filename, " ", e.toString); + Log.e("Editable.load: Exception while trying to read file ", filename, " ", e.toString); clear(); return false; }