Skip to content

Commit e29c1e0

Browse files
Add logging for import
1 parent 29de192 commit e29c1e0

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/main/java/main/exceptions/AqualitySQLException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private static String getErrorMessage(SQLException exception){
2727
}
2828
return String.format("You have missed required parameter: %s", exception.getMessage());
2929
case "HY000":
30-
return "Your Data Base does not support UTF characters, please contact administrator to allow it.";
30+
return String.format("Data base error: %s", exception.getMessage());
3131
case "42S02":
3232
return "There is some missed table in your Data Base, please contact administrator.";
3333
case "S1000":

src/main/java/main/model/db/imports/BaseImporter.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,23 @@ private void createTests() throws AqualityException {
154154
List<TestDto> completedTests = new ArrayList<>();
155155

156156
for (TestDto test : this.tests) {
157-
test.setProject_id(this.projectId);
158-
TestDto existingTest = tryGetExistingTest(allTests, test);
159-
160-
if (existingTest != null) {
161-
test.setId(existingTest.getId());
162-
} else {
163-
allTests.add(test);
164-
}
157+
try {
158+
test.setProject_id(this.projectId);
159+
TestDto existingTest = tryGetExistingTest(allTests, test);
160+
161+
if (existingTest != null) {
162+
test.setId(existingTest.getId());
163+
} else {
164+
allTests.add(test);
165+
}
165166

166-
test.setId(controllerFactory.getHandler(test).create(test, false).getId());
167-
linkTestToSuite(test);
167+
test.setId(controllerFactory.getHandler(test).create(test, false).getId());
168+
linkTestToSuite(test);
168169

169-
completedTests.add(test);
170+
completedTests.add(test);
171+
} catch (AqualityException exception) {
172+
logToImport(String.format("Was not able to create or update test:\n%s\nCreation was failed with error:\n%s", test.getName(), exception.getMessage()));
173+
}
170174
}
171175
this.tests = completedTests;
172176

@@ -207,9 +211,10 @@ private void createResult(TestResultDto result, boolean update) throws AqualityE
207211
}
208212
controllerFactory.getHandler(result).create(result);
209213
} catch (AqualityException e){
210-
throw e;
211-
} catch (Exception e){
212-
throw new AqualityException("Failed on Result Creation for test id: " + result.getTest_id());
214+
logToImport(
215+
String.format("Failed on Result Creation for test id:\n%s\nCreation was failed with error:\n%s",
216+
result.getTest_id(),
217+
e.getMessage()));
213218
}
214219
}
215220

@@ -246,7 +251,10 @@ private void updateResultWithSimilarError(TestResultDto result) throws AqualityE
246251
}
247252
}
248253
} catch (Exception e){
249-
throw new AqualityException("Failed on update Result with similar error");
254+
logToImport(
255+
String.format("Failed on predicting fail reason for test id:\n%s\nPrediction was failed with error:\n%s",
256+
result.getTest_id(),
257+
e.getMessage()));
250258
}
251259
}
252260

0 commit comments

Comments
 (0)