mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-13 16:39:48 +02:00
truncate long error messages on file load
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2008-08-21 Vadim Kurland <vadim@vk.crocodile.org>
|
||||||
|
|
||||||
|
* ProjectPanel_file_ops.cpp (ProjectPanel::load): truncating very
|
||||||
|
long error messages that happen when GUI tries to load broken .fwb
|
||||||
|
file. These error messages contain complete output of the XML
|
||||||
|
parser which can be very long and does not fit in the normal error
|
||||||
|
dialog. Message will be cut off at 1000 characters which is enough
|
||||||
|
to see the topmost part of the parser output.
|
||||||
|
|
||||||
2008-08-20 vadim <vadim@vk.crocodile.org>
|
2008-08-20 vadim <vadim@vk.crocodile.org>
|
||||||
|
|
||||||
* ObjectTreeView.cpp (ObjectTreeView::ObjectTreeView): Fixed GUI
|
* ObjectTreeView.cpp (ObjectTreeView::ObjectTreeView): Fixed GUI
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ SO_VERSION = @LIBFWBUILDER_SOLIB_VERSION@
|
|||||||
DEFINES += $$(DEFINES)
|
DEFINES += $$(DEFINES)
|
||||||
LANGUAGE = C++
|
LANGUAGE = C++
|
||||||
UI_DIR = ui
|
UI_DIR = ui
|
||||||
MANDIR = /home/vadim/src/fwb3/install_root/share/man/
|
MANDIR = /home/vadim/src/fwb3-branch-v3/install_root/share/man/
|
||||||
DOCDIR = /home/vadim/src/fwb3/install_root/share/doc/fwbuilder-3.0.0
|
DOCDIR = /home/vadim/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.0
|
||||||
|
|
||||||
HAVE_ANTLR_RUNTIME = 1
|
HAVE_ANTLR_RUNTIME = 1
|
||||||
HAVE_EXTERNAL_ANTLR = 0
|
HAVE_EXTERNAL_ANTLR = 0
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
ANTLR_INCLUDEPATH = /home/vadim/src/fwb3/source/fwbuilder/src/
|
ANTLR_INCLUDEPATH = /home/vadim/src/fwb3-branch-v3/source/fwbuilder/src/
|
||||||
ANTLR_LIBS = /home/vadim/src/fwb3/source/fwbuilder/src/antlr/libantlr.a
|
ANTLR_LIBS = /home/vadim/src/fwb3-branch-v3/source/fwbuilder/src/antlr/libantlr.a
|
||||||
FWBPARSER_LIB = ../parsers/libfwbparser.a
|
FWBPARSER_LIB = ../parsers/libfwbparser.a
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,32 +30,32 @@ unix {
|
|||||||
MOC_DIR = .moc
|
MOC_DIR = .moc
|
||||||
OBJECTS_DIR = .obj
|
OBJECTS_DIR = .obj
|
||||||
|
|
||||||
PREFIX = /home/vadim/src/fwb3/install_root
|
PREFIX = /home/vadim/src/fwb3-branch-v3/install_root
|
||||||
exec_prefix = @EXEC_PREFIX@
|
exec_prefix = @EXEC_PREFIX@
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
ICONSDIR = /home/vadim/src/fwb3/install_root/share//icons/hicolor/
|
ICONSDIR = /home/vadim/src/fwb3-branch-v3/install_root/share//icons/hicolor/
|
||||||
|
|
||||||
INCLUDEPATH += .. ../.. $$(INCLUDEPATH) /home/vadim/src/fwb3/install_root/include/ /home/vadim/src/fwb3/install_root/include/fwb-3 /usr/include/libxml2
|
INCLUDEPATH += .. ../.. $$(INCLUDEPATH) /home/vadim/src/fwb3-branch-v3/install_root/include/ /home/vadim/src/fwb3-branch-v3/install_root/include/fwb-3 /usr/include/libxml2
|
||||||
|
|
||||||
LIBS_FWCOMPILER = -L/home/vadim/src/fwb3/install_root/lib -Wl,-Bsymbolic-functions -pthread -lfwcompiler -lfwbuilder -lxslt -lxml2 -lnetsnmp
|
LIBS_FWCOMPILER = -L/home/vadim/src/fwb3-branch-v3/install_root/lib -pthread -lfwcompiler -lfwbuilder -lxslt -lxml2 -lnetsnmp -lm -lwrap
|
||||||
LIBS_FWBUILDER = -L/home/vadim/src/fwb3/install_root/lib -Wl,-Bsymbolic-functions -pthread -lfwbuilder -lxslt -lxml2 -lnetsnmp
|
LIBS_FWBUILDER = -L/home/vadim/src/fwb3-branch-v3/install_root/lib -pthread -lfwbuilder -lxslt -lxml2 -lnetsnmp -lm -lwrap
|
||||||
|
|
||||||
target.path = $$PREFIX/bin
|
target.path = $$PREFIX/bin
|
||||||
dtd.path = @TEMPLATE_DIR@/
|
dtd.path = @TEMPLATE_DIR@/
|
||||||
migration.path = @TEMPLATE_DIR@/migration
|
migration.path = @TEMPLATE_DIR@/migration
|
||||||
doc.path = /home/vadim/src/fwb3/install_root/share/doc/fwbuilder-3.0.0
|
doc.path = /home/vadim/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.0
|
||||||
datadir.path = /home/vadim/src/fwb3/install_root/share/
|
datadir.path = /home/vadim/src/fwb3-branch-v3/install_root/share/
|
||||||
|
|
||||||
|
|
||||||
# win32:target.path = $$PREFIX/
|
# win32:target.path = $$PREFIX/
|
||||||
# unix:target.path = $$PREFIX/share/fwbuilder/
|
# unix:target.path = $$PREFIX/share/fwbuilder/
|
||||||
# macx:target.path = $$PREFIX/
|
# macx:target.path = $$PREFIX/
|
||||||
|
|
||||||
res.path = /home/vadim/src/fwb3/install_root/share/fwbuilder-3.0.0
|
res.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0
|
||||||
res_os.path = /home/vadim/src/fwb3/install_root/share/fwbuilder-3.0.0/os/
|
res_os.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0/os/
|
||||||
res_platform.path = /home/vadim/src/fwb3/install_root/share/fwbuilder-3.0.0/platform/
|
res_platform.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0/platform/
|
||||||
res_help.path = /home/vadim/src/fwb3/install_root/share/fwbuilder-3.0.0/help/
|
res_help.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0/help/
|
||||||
res_desktop.path = /home/vadim/src/fwb3/install_root/share//applications/
|
res_desktop.path = /home/vadim/src/fwb3-branch-v3/install_root/share//applications/
|
||||||
|
|
||||||
INSTALLS += res
|
INSTALLS += res
|
||||||
INSTALLS += res_os
|
INSTALLS += res_os
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#define LONG_ERROR_CUTOFF 1024
|
||||||
|
|
||||||
using namespace Ui;
|
using namespace Ui;
|
||||||
using namespace libfwbuilder;
|
using namespace libfwbuilder;
|
||||||
@@ -524,7 +525,7 @@ void ProjectPanel::fileCompare()
|
|||||||
if (dobj) db1->remove(dobj, false);
|
if (dobj) db1->remove(dobj, false);
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("Error loading file %1:\n%2").
|
tr("Error loading file %1:\n%2").
|
||||||
arg(fname1).arg(ex.toString().c_str()),
|
arg(fname1).arg(ex.toString().c_str()),
|
||||||
@@ -543,7 +544,7 @@ void ProjectPanel::fileCompare()
|
|||||||
if (dobj) db2->remove(dobj, false);
|
if (dobj) db2->remove(dobj, false);
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("Error loading file %1:\n%2").
|
tr("Error loading file %1:\n%2").
|
||||||
arg(fname2).arg(ex.toString().c_str()),
|
arg(fname2).arg(ex.toString().c_str()),
|
||||||
@@ -615,7 +616,7 @@ void ProjectPanel::fileCompare()
|
|||||||
|
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("Unexpected error comparing files %1 and %2:\n%3").
|
tr("Unexpected error comparing files %1 and %2:\n%3").
|
||||||
arg(fname1).arg(fname2).arg(ex.toString().c_str()),
|
arg(fname1).arg(fname2).arg(ex.toString().c_str()),
|
||||||
@@ -845,7 +846,7 @@ void ProjectPanel::exportLibraryTo(QString fname,list<FWObject*> &selectedLibs,
|
|||||||
if (access( fname.toLatin1().constData(), W_OK)!=0 && errno==EACCES)
|
if (access( fname.toLatin1().constData(), W_OK)!=0 && errno==EACCES)
|
||||||
err=QObject::tr("File is read-only");
|
err=QObject::tr("File is read-only");
|
||||||
|
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
QObject::tr("Error saving file %1: %2")
|
QObject::tr("Error saving file %1: %2")
|
||||||
.arg(fname).arg(err),
|
.arg(fname).arg(err),
|
||||||
@@ -942,11 +943,17 @@ void ProjectPanel::loadLibrary(const string &libfpath)
|
|||||||
|
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QString error_txt = ex.toString().c_str();
|
||||||
|
if (error_txt.length() > LONG_ERROR_CUTOFF)
|
||||||
|
{
|
||||||
|
error_txt.truncate(LONG_ERROR_CUTOFF);
|
||||||
|
error_txt += "\n\n" + tr("(Long error message was truncated)");
|
||||||
|
}
|
||||||
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("The program encountered error trying to load file %1.\n"
|
tr("The program encountered error trying to load file %1.\n"
|
||||||
"The file has not been loaded. Error:\n%2").
|
"The file has not been loaded. Error:\n%2").
|
||||||
arg(libfpath.c_str()).arg(ex.toString().c_str()),
|
arg(libfpath.c_str()).arg(error_txt),
|
||||||
tr("&Continue"), QString::null,QString::null,
|
tr("&Continue"), QString::null,QString::null,
|
||||||
0, 1 );
|
0, 1 );
|
||||||
}
|
}
|
||||||
@@ -1010,7 +1017,7 @@ void ProjectPanel::load(QWidget*)
|
|||||||
|
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("Error loading file:\n%1").arg(ex.toString().c_str()),
|
tr("Error loading file:\n%1").arg(ex.toString().c_str()),
|
||||||
tr("&Continue"), QString::null,QString::null,
|
tr("&Continue"), QString::null,QString::null,
|
||||||
@@ -1205,32 +1212,45 @@ void ProjectPanel::load(QWidget*,
|
|||||||
|
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
string trans = ex.getProperties()["failed_transformation"];
|
QString trans = ex.getProperties()["failed_transformation"].c_str();
|
||||||
string elem = ex.getProperties()["failed_element"];
|
QString elem = ex.getProperties()["failed_element"].c_str();
|
||||||
|
|
||||||
if(!trans.empty() || !elem.empty())
|
if(!trans.isEmpty() || !elem.isEmpty())
|
||||||
{
|
{
|
||||||
QString msg = tr("Exception: %1").arg(ex.toString().c_str());
|
QString msg = tr("Exception: %1").arg(ex.toString().c_str());
|
||||||
if (!trans.empty())
|
if (!trans.isEmpty())
|
||||||
msg+="\n"+tr("Failed transformation : %1").arg(trans.c_str());
|
{
|
||||||
if (!elem.empty())
|
trans.truncate(LONG_ERROR_CUTOFF);
|
||||||
msg+="\n"+tr("XML element : %1").arg(elem.c_str());
|
msg+="\n"+tr("Failed transformation : %1").arg(trans);
|
||||||
|
}
|
||||||
QMessageBox::warning(
|
if (!elem.isEmpty())
|
||||||
this,"Firewall Builder",
|
{
|
||||||
tr("The program encountered error trying to load data file.\n"
|
elem.truncate(LONG_ERROR_CUTOFF);
|
||||||
"The file has not been loaded. Error:\n%1").arg(msg),
|
msg+="\n"+tr("XML element : %1").arg(elem);
|
||||||
tr("&Continue"), QString::null,QString::null,
|
}
|
||||||
0, 1 );
|
QMessageBox::critical(
|
||||||
|
this,"Firewall Builder",
|
||||||
|
tr("The program encountered error trying to load data file.\n"
|
||||||
|
"The file has not been loaded. Error:\n%1").arg(msg),
|
||||||
|
tr("&Continue"), QString::null,QString::null,
|
||||||
|
0, 1 );
|
||||||
} else
|
} else
|
||||||
QMessageBox::warning(
|
{
|
||||||
this,"Firewall Builder",
|
QString error_txt = ex.toString().c_str();
|
||||||
tr("The program encountered error trying to load data file.\n"
|
if (error_txt.length() > LONG_ERROR_CUTOFF)
|
||||||
"The file has not been loaded. Error:\n%1").arg(
|
{
|
||||||
ex.toString().c_str()),
|
error_txt.truncate(LONG_ERROR_CUTOFF);
|
||||||
tr("&Continue"), QString::null,QString::null,
|
error_txt += "\n\n" + tr("(Long error message was truncated)");
|
||||||
0, 1 );
|
}
|
||||||
|
|
||||||
|
QMessageBox::critical(
|
||||||
|
this,"Firewall Builder",
|
||||||
|
tr("The program encountered error trying to load data file.\n"
|
||||||
|
"The file has not been loaded. Error:\n%1").arg(
|
||||||
|
error_txt),
|
||||||
|
tr("&Continue"), QString::null,QString::null,
|
||||||
|
0, 1 );
|
||||||
|
}
|
||||||
load(this);
|
load(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1498,31 +1518,45 @@ void ProjectPanel::load(QWidget*, RCS *_rcs)
|
|||||||
|
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
string trans = ex.getProperties()["failed_transformation"];
|
QString trans = ex.getProperties()["failed_transformation"].c_str();
|
||||||
string elem = ex.getProperties()["failed_element"];
|
QString elem = ex.getProperties()["failed_element"].c_str();
|
||||||
|
|
||||||
if(!trans.empty() || !elem.empty())
|
if(!trans.isEmpty() || !elem.isEmpty())
|
||||||
{
|
{
|
||||||
QString msg = tr("Exception: %1").arg(ex.toString().c_str());
|
QString msg = tr("Exception: %1").arg(ex.toString().c_str());
|
||||||
if (!trans.empty())
|
if (!trans.isEmpty())
|
||||||
msg+="\n"+tr("Failed transformation : %1").arg(trans.c_str());
|
{
|
||||||
if (!elem.empty())
|
trans.truncate(LONG_ERROR_CUTOFF);
|
||||||
msg+="\n"+tr("XML element : %1").arg(elem.c_str());
|
msg+="\n"+tr("Failed transformation : %1").arg(trans);
|
||||||
|
}
|
||||||
QMessageBox::warning(
|
if (!elem.isEmpty())
|
||||||
|
{
|
||||||
|
elem.truncate(LONG_ERROR_CUTOFF);
|
||||||
|
msg+="\n"+tr("XML element : %1").arg(elem);
|
||||||
|
}
|
||||||
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("The program encountered error trying to load data file.\n"
|
tr("The program encountered error trying to load data file.\n"
|
||||||
"The file has not been loaded. Error:\n%1").arg(msg),
|
"The file has not been loaded. Error:\n%1").arg(msg),
|
||||||
tr("&Continue"), QString::null,QString::null,
|
tr("&Continue"), QString::null,QString::null,
|
||||||
0, 1 );
|
0, 1 );
|
||||||
} else
|
} else
|
||||||
QMessageBox::warning(
|
{
|
||||||
|
QString error_txt = ex.toString().c_str();
|
||||||
|
if (error_txt.length() > LONG_ERROR_CUTOFF)
|
||||||
|
{
|
||||||
|
error_txt.truncate(LONG_ERROR_CUTOFF);
|
||||||
|
error_txt += "\n\n" + tr("(Long error message was truncated)");
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("The program encountered error trying to load data file.\n"
|
tr("The program encountered error trying to load data file.\n"
|
||||||
"The file has not been loaded. Error:\n%1").arg(
|
"The file has not been loaded. Error:\n%1").arg(
|
||||||
ex.toString().c_str()),
|
error_txt),
|
||||||
tr("&Continue"), QString::null,QString::null,
|
tr("&Continue"), QString::null,QString::null,
|
||||||
0, 1 );
|
0, 1 );
|
||||||
|
}
|
||||||
// load standard objects so the window does not remain empty
|
// load standard objects so the window does not remain empty
|
||||||
load(this);
|
load(this);
|
||||||
return;
|
return;
|
||||||
@@ -1597,7 +1631,7 @@ bool ProjectPanel::checkin(bool unlock)
|
|||||||
}
|
}
|
||||||
catch (FWException &ex)
|
catch (FWException &ex)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("Error checking in file %1:\n%2")
|
tr("Error checking in file %1:\n%2")
|
||||||
.arg(rcs->getFileName()).arg(ex.toString().c_str()),
|
.arg(rcs->getFileName()).arg(ex.toString().c_str()),
|
||||||
@@ -1687,7 +1721,7 @@ void ProjectPanel::save()
|
|||||||
else
|
else
|
||||||
err=ex.toString().c_str();
|
err=ex.toString().c_str();
|
||||||
|
|
||||||
QMessageBox::warning(
|
QMessageBox::critical(
|
||||||
this,"Firewall Builder",
|
this,"Firewall Builder",
|
||||||
tr("Error saving file %1: %2")
|
tr("Error saving file %1: %2")
|
||||||
.arg(rcs->getFileName()).arg(err),
|
.arg(rcs->getFileName()).arg(err),
|
||||||
|
|||||||
Reference in New Issue
Block a user