Business errors differenciated from technical errors in the Lambda runner

This commit is contained in:
Gaël Métais
2021-04-11 13:14:35 +01:00
parent 201bf75bf7
commit 163eef58c2
5 changed files with 45 additions and 16 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ var yellowLabTools = function(url, options) {
.then(function(data) {
// If a screenshot saveFunction was provided in the options
if (typeof options.saveFile === 'function') {
if (typeof options.saveScreenshotFn === 'function') {
debug('Now optimizing screenshot...');
// Remove uneeded temp screenshot path
@@ -42,7 +42,7 @@ var yellowLabTools = function(url, options) {
.then(function(screenshotBuffer) {
debug('Screenshot optimized, now saving...');
return options.saveFile('screenshot.jpg', screenshotBuffer);
return options.saveScreenshotFn('screenshot.jpg', screenshotBuffer);
})
.then(function(response) {
+7 -7
View File
@@ -94,15 +94,15 @@ var screenshotHandler = function() {
this.deleteTmpFile = function(tmpFilePath) {
var deferred = Q.defer();
fs.unlink(this.getTmpFileRelativePath(), function (err) {
if (err) {
debug('Screenshot temporary file not found, could not be deleted. But it is not a problem.');
} else {
debug('Screenshot temporary file deleted.');
}
//fs.unlink(this.getTmpFileRelativePath(), function (err) {
// if (err) {
// debug('Screenshot temporary file not found, could not be deleted. But it is not a problem.');
// } else {
// debug('Screenshot temporary file deleted.');
// }
deferred.resolve();
});
//});
return deferred.promise;
};
+2 -1
View File
@@ -102,7 +102,8 @@ var ApiController = function(app) {
if (response.StatusCode === 200 && response.Payload && response.Payload !== 'null') {
const payload = JSON.parse(response.Payload);
if (payload.errorType) {
if (payload.status === 'failed') {
debug('Failed with error %s', payload.errorMessage);
runsDatastore.markAsFailed(run.runId, payload.errorMessage);
} else {
debug('Success!');