[netcf-devel] [PATCH 2/4] Improve error reporting when stylesheets/interface.rng can't be loaded
David Lutterkort
lutter at redhat.com
Thu Oct 15 15:23:58 UTC 2009
* src/dutil.c (parse_stylesheet): set an error if stylesheet parsing
fails; (rng_parse): do the same for loading the Relax NG grammar
Fixes BZ 528931
---
src/dutil.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/src/dutil.c b/src/dutil.c
index ff64afa..9ae80bf 100644
--- a/src/dutil.c
+++ b/src/dutil.c
@@ -253,8 +253,17 @@ xsltStylesheetPtr parse_stylesheet(struct netcf *ncf,
r = xasprintf(&path, "%s/xml/%s", ncf->data_dir, fname);
ERR_NOMEM(r < 0, ncf);
- // FIXME: Error checking ??
+ if (access(path, R_OK) < 0) {
+ report_error(ncf, NETCF_EFILE,
+ "Stylesheet %s does not exist or is not readable",
+ path);
+ goto error;
+ }
+
result = xsltParseStylesheetFile(BAD_CAST path);
+ ERR_THROW(result == NULL, ncf, EFILE,
+ "Could not parse stylesheet %s", path);
+
error:
free(path);
return result;
@@ -338,6 +347,12 @@ xmlRelaxNGPtr rng_parse(struct netcf *ncf, const char *fname) {
r = xasprintf(&path, "%s/xml/%s", ncf->data_dir, fname);
ERR_NOMEM(r < 0, ncf);
+ if (access(path, R_OK) < 0) {
+ report_error(ncf, NETCF_EFILE,
+ "File %s does not exist or is not readable", path);
+ goto error;
+ }
+
ctxt = xmlRelaxNGNewParserCtxt(path);
xmlRelaxNGSetParserErrors(ctxt, rng_error, rng_error, ncf);
--
1.6.2.5
More information about the netcf-devel
mailing list