Skip to content
Snippets Groups Projects
Commit 89757f72 authored by gmantele's avatar gmantele
Browse files

[TAP] Add line and column information in log and exception messages for the UPLOAD step.

parent 62a6c73f
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ package tap.db; ...@@ -16,7 +16,7 @@ package tap.db;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>. * along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -145,7 +145,7 @@ import adql.translator.TranslationException; ...@@ -145,7 +145,7 @@ import adql.translator.TranslationException;
* </i></p> * </i></p>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (03/2015) * @version 2.0 (04/2015)
* @since 2.0 * @since 2.0
*/ */
public class JDBCConnection implements DBConnection { public class JDBCConnection implements DBConnection {
...@@ -1782,22 +1782,28 @@ public class JDBCConnection implements DBConnection { ...@@ -1782,22 +1782,28 @@ public class JDBCConnection implements DBConnection {
val = new Timestamp(ISO8601Format.parse(val.toString())); val = new Timestamp(ISO8601Format.parse(val.toString()));
}catch(ParseException pe){ }catch(ParseException pe){
if (logger != null) if (logger != null)
logger.logDB(LogLevel.ERROR, this, "UPLOAD", "Unexpected date format for the " + c + "-th column (" + val + ")! A date formatted in ISO8601 was expected.", pe); logger.logDB(LogLevel.ERROR, this, "UPLOAD", "[l. " + nbRows + ", c. " + c + "] Unexpected date format for the value: \"" + val + "\"! A date formatted in ISO8601 was expected.", pe);
throw new DBException("Unexpected date format for the " + c + "-th column (" + val + ")! A date formatted in ISO8601 was expected.", pe); throw new DBException("[l. " + nbRows + ", c. " + c + "] Unexpected date format for the value: \"" + val + "\"! A date formatted in ISO8601 was expected.", pe);
} }
} }
/* GEOMETRY FORMATTING */ /* GEOMETRY FORMATTING */
else if (cols[c - 1].getDatatype().type == DBDatatype.POINT || cols[c - 1].getDatatype().type == DBDatatype.REGION){ else if (cols[c - 1].getDatatype().type == DBDatatype.POINT || cols[c - 1].getDatatype().type == DBDatatype.REGION){
Region region; Region region;
try{
// parse the region as an STC-S expression: // parse the region as an STC-S expression:
try{
region = STCS.parseRegion(val.toString()); region = STCS.parseRegion(val.toString());
}catch(adql.parser.ParseException e){
if (logger != null)
logger.logDB(LogLevel.ERROR, this, "UPLOAD", "[l. " + nbRows + ", c. " + c + "] Incorrect STC-S syntax for the geometrical value \"" + val + "\"! " + e.getMessage(), e);
throw new DataReadException("[l. " + nbRows + ", c. " + c + "] Incorrect STC-S syntax for the geometrical value \"" + val + "\"! " + e.getMessage(), e);
}
// translate this STC region into the corresponding column value: // translate this STC region into the corresponding column value:
try{
val = translator.translateGeometryToDB(region); val = translator.translateGeometryToDB(region);
}catch(adql.parser.ParseException e){ }catch(adql.parser.ParseException e){
if (logger != null) if (logger != null)
logger.logDB(LogLevel.ERROR, this, "UPLOAD", "Incorrect STC-S syntax for the geometrical value \"" + val + "\"!", e); logger.logDB(LogLevel.ERROR, this, "UPLOAD", "[l. " + nbRows + ", c. " + c + "] Impossible to import the ADQL geometry \"" + val + "\" into the database! " + e.getMessage(), e);
throw new DataReadException("Incorrect STC-S syntax for the geometrical value \"" + val + "\"!", e); throw new DataReadException("[l. " + nbRows + ", c. " + c + "] Impossible to import the ADQL geometry \"" + val + "\" into the database! " + e.getMessage(), e);
} }
} }
/* BOOLEAN CASE (more generally, type incompatibility) */ /* BOOLEAN CASE (more generally, type incompatibility) */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment