[gnote] Add exception handling code when writing note
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add exception handling code when writing note
- Date: Fri, 1 Mar 2013 22:24:15 +0000 (UTC)
commit c39ff13477abbe1de0471596e5c814bebcb4b599
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Mar 2 00:14:02 2013 +0200
Add exception handling code when writing note
src/note.cpp | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index 8b392fe..9af4779 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -1130,10 +1130,16 @@ namespace gnote {
sharp::XmlReader xml(file);
NoteData *data = _read(xml, uri, version);
if(version != NoteArchiver::CURRENT_VERSION) {
- // Note has old format, so rewrite it. No need
- // to reread, since we are not adding anything.
- DBG_OUT("Updating note XML from %s to newest format...", version.c_str());
- NoteArchiver::write(file, *data);
+ try {
+ // Note has old format, so rewrite it. No need
+ // to reread, since we are not adding anything.
+ DBG_OUT("Updating note XML from %s to newest format...", version.c_str());
+ NoteArchiver::write(file, *data);
+ }
+ catch(sharp::Exception & e) {
+ // write failure, but not critical
+ ERR_OUT("Failed to update note format: %s", e.what());
+ }
}
return data;
}
@@ -1244,13 +1250,13 @@ namespace gnote {
void NoteArchiver::write_file(const std::string & _write_file, const NoteData & note)
{
- std::string tmp_file = _write_file + ".tmp";
- // TODO Xml doc settings
- sharp::XmlWriter xml(tmp_file); //, XmlEncoder::DocumentSettings);
- write(xml, note);
- xml.close ();
-
try {
+ std::string tmp_file = _write_file + ".tmp";
+ // TODO Xml doc settings
+ sharp::XmlWriter xml(tmp_file); //, XmlEncoder::DocumentSettings);
+ write(xml, note);
+ xml.close();
+
if (sharp::file_exists(_write_file)) {
std::string backup_path = _write_file + "~";
if (sharp::file_exists(backup_path)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]