Skip to content

Commit

Permalink
[MIN] XQuery, Geo Module: better error feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianGruen committed Mar 27, 2014
1 parent 500c70b commit ae09612
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
4 changes: 2 additions & 2 deletions basex-api/src/main/java/org/expath/ns/Geo.java
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ private Geometry geo(final ANode node, final QNm... names) throws QueryException
final GMLReader gmlReader = new GMLReader();
final GeometryFactory geoFactory = new GeometryFactory();
return gmlReader.read(input, geoFactory);
} catch (final Throwable e) {
throw GeoErrors.gmlReaderErr(e);
} catch(final Throwable ex) {
throw GeoErrors.gmlReaderErr(ex);
}
}
return null;
Expand Down
45 changes: 22 additions & 23 deletions basex-api/src/main/java/org/expath/ns/GeoErrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@ private GeoErrors() { }

/**
* GEO0001: Unrecognized geo object.
* @param element Geometry object
* @param name name of element
* @return query exception
*/
static QueryException unrecognizedGeo(final Object element) {
return thrw(1, "Unrecognized Geo type: %", element);
static QueryException unrecognizedGeo(final byte[] name) {
return thrw(1, "Unrecognized Geo type: %", name);
}

/**
* GEO0002: gml reader error massage (JTS).
* @param e error
* GEO0002: GML reader error massage (JTS).
* @param th throwable
* @return query exception
*/
static QueryException gmlReaderErr(final Object e) {
return thrw(2, "%", e);
static QueryException gmlReaderErr(final Throwable th) {
return thrw(2, "Parsing GML 2.0: %", th);
}

/**
* GEO0003: Inappropriate input geometry.
* @param input Geometry object
* @param name name of element
* @param geo exact Geometry object
* @return query exception
*/
static QueryException geoType(final Object input, final String geo) {
static QueryException geoType(final byte[] name, final String geo) {
return thrw(3, "% is not an appropiate geometry for this function. "
+ "The input geometry should be a %.", input, geo);
+ "The input geometry should be a %.", name, geo);
}

/**
Expand All @@ -60,32 +60,31 @@ static QueryException outOfRangeIdx(final Int geoNumber) {


/**
* GEO0005: gml writer error massage (JTS).
* @param e error
* GEO0005: GML writer error massage (JTS).
* @param th throwable
* @return query exception
*/
static QueryException gmlWriterErr(final Object e) {
return thrw(5, "%", e);
static QueryException gmlWriterErr(final Throwable th) {
return thrw(5, "%", th);
}

/**
* Returns a query exception.
* Creates an error QName for the specified code.
* @param code code
* @param msg message
* @param ext extension
* @return query exception
*/
private static QueryException thrw(final int code, final String msg,
final Object... ext) {
return new QueryException(null, qname(code), msg, ext);
static QNm qname(final int code) {
return new QNm(String.format("%s:GEO%04d", PREFIX, code), NS);
}

/**
* Creates an error QName for the specified code.
* Returns a query exception.
* @param code code
* @param msg message
* @param ext extension
* @return query exception
*/
public static QNm qname(final int code) {
return new QNm(String.format("%s:GEO%04d", PREFIX, code), NS);
private static QueryException thrw(final int code, final String msg, final Object... ext) {
return new QueryException(null, qname(code), msg, ext);
}
}

0 comments on commit ae09612

Please sign in to comment.