Commit 026b675b authored by rafaelatc3sl's avatar rafaelatc3sl Committed by Rafael Dias

Issue #105: Update error messages

Signed-off-by: default avatarrafaelatc3sl <rpd17@c3sl>
parent d0337249
Pipeline #21204 passed with stages
in 1 minute and 20 seconds
......@@ -111,7 +111,8 @@ describe("API collect controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The source named 'thisisjustatest' was not found";
const error = "[Engine Error] Required Source: 'thisisjustatest' do not exist in the database."+
" Check source spelling and database configuration.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -133,7 +134,8 @@ describe("API collect controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The 'name' wasn't informed on json";
const error = "[Collect error] 'name' is mandatory, but no data was received."+
" Review the data sent.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -176,7 +178,8 @@ describe("API collect controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value 'thisisjustatest' from 'sex' isn't listed on enumsex";
const error = "[Collect error] EnumType: 'thisisjustatest' from 'sex' isn't allowed on enumsex."
+ " Review configuration files."
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -199,7 +202,8 @@ describe("API collect controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value 'nope' from 'id' isn't a type integer";
const error = "[Collect error] Datatype: 'nope' from 'id' could not be converted to type: integer."+
" Review configuration files."
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -222,7 +226,8 @@ describe("API collect controller", () => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value 'notafloat' from 'pricein' isn't a type float";
const error = "[Collect error] Datatype: 'notafloat' from 'pricein' could not be converted to type: float." +
" Review configuration files."
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -243,7 +248,8 @@ describe("API collect controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value '5' from 'name' isn't a type string";
const error = "[Collect error] Datatype: '5' from 'name' could not be converted to type: string."+
" Review configuration files.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -267,7 +273,8 @@ describe("API collect controller", () => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value 'notaboolean' from 'Registered' isn't a type boolean";
const error = "[Collect error] Datatype: 'notaboolean' from 'Registered' could not be converted to type: boolean."+
" Review configuration files.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -292,7 +299,8 @@ describe("API collect controller", () => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value '1999-25-25' from 'Datein' isn't a type date";
const error = "[Collect error] Datatype: '1999-25-25' from 'Datein' could not be converted to type: date." +
" Review configuration files.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......@@ -317,7 +325,8 @@ describe("API collect controller", () => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The value '1999/12/12' from 'Datein' isn't a type date";
const error = "[Collect error] Datatype: '1999/12/12' from 'Datein' could not be converted to type: date."+
" Review configuration files.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body.message).to.be.eql(message);
......
......@@ -133,8 +133,8 @@ export class CollectCtrl {
// true/false, it must guarantee that it isn't a boolean
// then it'll test if it's empty
if (!(typeof(data[i]) === "boolean") && !data[i]){
throw new Error(
"The '" + fields[i].name + "' wasn't informed on json");
throw new Error("[Collect error] '" + fields[i].name +
"' is mandatory, but no data was received. Review the data sent.");
}
}
......@@ -151,14 +151,14 @@ export class CollectCtrl {
}
}
if (!found) {
throw new Error(
"The value '" + data[i] + "' from '" + fields[i].name +
"' isn't listed on " + fields[i].enumType);
throw new Error("[Collect error] EnumType: '" + data[i] + "' from '" + fields[i].name +
"' isn't allowed on " + fields[i].enumType +
". Review configuration files.");
}
}else if (!validador[EnumHandler.stringfyDataType(fields[i].dataType)](data[i]) === true){
throw new Error(
"The value '" + data[i] + "' from '" + fields[i].name +
"' isn't a type " + [EnumHandler.stringfyDataType(fields[i].dataType)]);
throw new Error("[Collect error] Datatype: '" + data[i] + "' from '" + fields[i].name +
"' could not be converted to type: " + [EnumHandler.stringfyDataType(fields[i].dataType)] +
". Review configuration files.");
}
}
}
......
......@@ -55,8 +55,8 @@ describe("API data controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The metric named met:this:is:just:a:test" +
" was not found";
const error = "[Engine Error] Metric: 'met:this:is:just:a:test' do not exist in the database." +
" Check metric spelling and database configuration.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body).to.have.property("error");
......@@ -74,8 +74,8 @@ describe("API data controller", () => {
.expect((res: any) => {
const message = "Query execution failed: " +
"Could not construct query with the given parameters.";
const error = "The dimension named dim:this:is:just:a:test" +
" was not found";
const error = "[Engine Error] Dimension: 'dim:this:is:just:a:test' do not exist in the database."+
" Check dimension spelling and database configuration.";
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("message");
expect(res.body).to.have.property("error");
......
......@@ -55,7 +55,7 @@ describe("engine class", () => {
}
catch (e){
error = true;
expect(e.message).to.be.equal("Engine views cannot cover the query");
expect(e.message).to.be.equal("[Engine Error] Engine views cannot cover the query");
}
expect(error);
......@@ -68,7 +68,7 @@ describe("engine class", () => {
}
catch (e){
error = true;
expect(e.message).to.be.equal("Engine views cannot cover the query");
expect(e.message).to.be.equal("[Engine Error] Engine views cannot cover the query");
}
expect(error);
......@@ -132,7 +132,7 @@ describe("engine class", () => {
}
catch (e){
error = true;
expect(e.message).to.be.equal("Engine views cannot cover the query");
expect(e.message).to.be.equal("[Engine Error] Engine views cannot cover the query");
}
expect(error).to.be.true;
......@@ -175,7 +175,7 @@ describe("engine class", () => {
it("should throw an exception, when a dimension is not found", () => {
let error: boolean = false;
const strFilter = "dim:seller:willfail==teste";
const exeption = "Filter could not be created: \"dim:seller:willfail\" was not found";
const exeption = "[Engine Error] Filter could not be created: \"dim:seller:willfail\" was not found. Check target spelling.";
try {
engine.parseClause(strFilter);
}
......@@ -190,7 +190,7 @@ describe("engine class", () => {
it("should throw an exception, when a metric is not found", () => {
let error: boolean = false;
const strFilter = "met:seller:count:willfail==0";
const exeption = "Filter could not be created: \"met:seller:count:willfail\" was not found";
const exeption = "[Engine Error] Filter could not be created: \"met:seller:count:willfail\" was not found. Check target spelling.";
try {
engine.parseClause(strFilter);
}
......@@ -205,7 +205,7 @@ describe("engine class", () => {
it("should throw an exception, when a operator is not found", () => {
let error: boolean = false;
let strFilter = "met:sell:sum:quantity=?0";
let exeption = "Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted";
let exeption = "[Engine Error] Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted";
try {
engine.parseClause(strFilter);
}
......@@ -217,7 +217,7 @@ describe("engine class", () => {
expect(error).to.be.true;
error = false;
strFilter = "met:sell:sum:quantity!?0";
exeption = "Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted";
exeption = "[Engine Error] Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted";
try {
engine.parseClause(strFilter);
}
......@@ -234,7 +234,7 @@ describe("engine class", () => {
for (let i = 0; i < operators.length; ++i) {
let error: boolean = false;
let strFilter = "dim:client:name" + operators[i] + "Firoz";
let exeption = "Filter could not be created: Operator \"" + operators[i] + "\" is invalid for target \"dim:client:name\"";
let exeption = "[Engine Error] Filter could not be created: Operator \"" + operators[i] + "\" is invalid for target \"dim:client:name\"";
try {
engine.parseClause(strFilter);
}
......@@ -323,7 +323,8 @@ describe("engine class", () => {
}
catch (e){
error = true;
expect(e.message).to.be.equal("The dataType named 'test' was not found");
expect(e.message).to.be.equal("[Engine Error] EnumType: 'test' do not exist in the database." +
" Check enumtype spelling and database configuration.");
}
expect(error);
});
......
......@@ -201,7 +201,8 @@ export class Engine {
let result = this.metrics.find(metric => metric.name === name);
if (!result) {
throw new Error("The metric named " + name + " was not found");
throw new Error("[Engine Error] Metric: '" + name + "' do not exist in the database." +
" Check metric spelling and database configuration.");
}
return result;
......@@ -215,7 +216,8 @@ export class Engine {
let result = this.enumTypes.find(EnumType => EnumType.name === name);
if (!result) {
throw new Error("The dataType named '" + name + "' was not found");
throw new Error("[Engine Error] EnumType: '" + name + "' do not exist in the database." +
" Check enumtype spelling and database configuration.");
}
return result;
......@@ -229,7 +231,8 @@ export class Engine {
let result = this.sources.find(source => source.name === name);
if (!result) {
throw new Error("The source named '" + name + "' was not found");
throw new Error("[Engine Error] Required Source: '" + name + "' do not exist in the database." +
" Check source spelling and database configuration.");
}
return result;
......@@ -256,7 +259,8 @@ export class Engine {
let result = this.dimensions.find(dimension => dimension.name === name);
if (!result) {
throw new Error("The dimension named " + name + " was not found");
throw new Error("[Engine Error] Dimension: '" + name + "' do not exist in the database." +
" Check dimension spelling and database configuration.");
}
return result;
......@@ -301,7 +305,7 @@ export class Engine {
}
if (!target) {
throw new Error("Filter could not be created: \"" + segment.target + "\" was not found");
throw new Error("[Engine Error] Filter could not be created: \"" + segment.target + "\" was not found. Check target spelling.");
}
const filter = new Filter({
......@@ -311,13 +315,13 @@ export class Engine {
});
if (!filter.isValid) {
throw new Error("Filter could not be created: Operator \"" + segment.operator + "\" is invalid for target \"" + segment.target + "\"");
throw new Error("[Engine Error] Filter could not be created: Operator \"" + segment.operator + "\" is invalid for target \"" + segment.target + "\"");
}
return filter;
}
else {
throw new Error("Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted");
throw new Error("[Engine Error] Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted");
}
}
......@@ -378,7 +382,7 @@ export class Engine {
private getCover (q: Query): View[] {
const optimalViews = this.graph.cover(q);
if (optimalViews.length === 0) {
throw new Error ("Engine views cannot cover the query");
throw new Error("[Engine Error] Engine views cannot cover the query");
}
let matViews: View[] = optimalViews.sort((a, b) => (a.id < b.id) ? -1 : 1);
......
......@@ -56,7 +56,8 @@ describe("configParser utility library", () => {
catch (e) {
error = true;
expect(e.message).to.be
.equal("[Parsing error] Non exist metric set to view " + opts.alias);
.equal("[Parsing error] Metric: 'met:-1' do not exist on view: Test." +
" Review configuration files.");
}
expect(error).to.be.true;
......@@ -77,7 +78,8 @@ describe("configParser utility library", () => {
catch (e) {
error = true;
expect(e.message).to.be
.equal("[Parsing error] Non exist dimension set to view " + opts.alias);
.equal("[Parsing error] Dimension: 'dim:-1' do not exist on view: Test." +
" Review configuration files.");
}
expect(error).to.be.true;
......@@ -100,7 +102,8 @@ describe("configParser utility library", () => {
catch (e) {
error = true;
expect(e.message).to.be
.equal("[Parsing error] Parent for subdimension " + opts.name + " not found");
.equal("[Parsing error] Dimension has been defined with invalid Parent for subdimension: 'dim:-1'." +
" Review Parent spelling in dimension and configuration files.");
}
expect(error).to.be.true;
......@@ -245,7 +248,8 @@ describe("configParser utility library", () => {
catch (e) {
error = true;
expect(e.message).to.be
.equal("[Parsing error] DataType: '" + opts.dataType + "' does not exist on Dimension");
.equal("[Parsing error] Dimension has been defined with invalid DataType: 'enumtype:4'." +
" Review DataType spelling in dimension and configuration files.");
}
expect(error).to.be.true;
......@@ -266,7 +270,8 @@ describe("configParser utility library", () => {
catch (e) {
error = true;
expect(e.message).to.be
.equal("[Parsing error] DataType: '" + met.dataType + "' does not exist on Metric");
.equal("[Parsing error] Metrics has been defined with invalid DataType: 'string'." +
" Review DataType spelling in metrics and configuration files");
}
expect(error).to.be.true;
......@@ -296,7 +301,8 @@ describe("configParser utility library", () => {
catch (e) {
error = true;
expect(e.message).to.be
.equal("[Parsing error] EnumType: '" + sourc.fields[1].enumType + "' does not exist on Source");
.equal("[Parsing error] EnumType has been defined with invalid DataType: 'enumtype:10'." +
" Review EnumType spelling in source and configuration files");
}
expect(error).to.be.true;
});
......
......@@ -352,7 +352,8 @@ export class ConfigParser {
}
else {
throw new Error("[Parsing error] Non exist metric set to view " + opts.alias);
throw new Error("[Parsing error] Metric: '" + opts.metrics[i] + "' do not exist on view: " + opts.alias +
". Review configuration files.");
}
}
......@@ -363,7 +364,8 @@ export class ConfigParser {
}
else {
throw new Error("[Parsing error] Non exist dimension set to view " + opts.alias);
throw new Error("[Parsing error] Dimension: '" + opts.dimensions[i] + "' do not exist on view: " + opts.alias +
". Review configuration files.");
}
}
......@@ -393,11 +395,13 @@ export class ConfigParser {
public static parseDimOpts (opts: DimensionStrOptions, dims: Dimension[], map: EnumTypeMap, tagMap: TagMap): DimensionOptions {
let type = EnumHandler.parseDataType(opts.dataType);
if (type === DataType.NONE) {
throw new Error("[Parsing error] DataType: '" + opts.dataType + "' does not exist on Dimension");
throw new Error("[Parsing error] Dimension has been defined with invalid DataType: '" + opts.dataType +
"'. Review DataType spelling in dimension and configuration files.");
}
else if (type === DataType.ENUMTYPE) {
if (!(map[opts.enumType])) {
throw new Error("[Parsing error] EnumType: '" + opts.enumType + "' does not exist on Dimension");
throw new Error("[Parsing error] Dimension has been defined with invalid EnumType: '" + opts.enumType +
"'. Review Enumtype spelling in dimension and configuration files.");
}
}
let tags: Tag[] = [];
......@@ -426,7 +430,8 @@ export class ConfigParser {
}
}
throw new Error("[Parsing error] Parent for subdimension " + opts.name + " not found");
throw new Error("[Parsing error] Dimension has been defined with invalid Parent for subdimension: '" + opts.name +
"'. Review Parent spelling in dimension and configuration files.");
}
return {
name: opts.name,
......@@ -448,7 +453,8 @@ export class ConfigParser {
let type = EnumHandler.parseDataType(opts.dataType);
if (!(type === DataType.FLOAT || type === DataType.INTEGER)){
throw new Error("[Parsing error] DataType: '" + opts.dataType + "' does not exist on Metric");
throw new Error("[Parsing error] Metrics has been defined with invalid DataType: '" + opts.dataType +
"'. Review DataType spelling in metrics and configuration files");
}
......@@ -502,11 +508,13 @@ export class ConfigParser {
for ( let k = 0; k < opts.fields.length ; k++) {
let type = EnumHandler.parseDataType(opts.fields[k].dataType);
if (type === DataType.NONE) {
throw new Error("[Parsing error] DataType: '" + opts.fields[k].dataType + "' does not exist on Source");
throw new Error("[Parsing error] Source has been defined with invalid DataType: '" + opts.fields[k].dataType +
"'. Review DataType spelling in source and configuration files");
}
else if (type === DataType.ENUMTYPE){
if (!(map[opts.fields[k].enumType])){
throw new Error("[Parsing error] EnumType: '" + opts.fields[k].enumType + "' does not exist on Source");
throw new Error("[Parsing error] EnumType has been defined with invalid DataType: '" + opts.fields[k].enumType +
"'. Review EnumType spelling in source and configuration files");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment