This article explains how to generate an error if an FTP request attempts to read a file from an empty location. The following code sample contains a JavaScript function that can be used to check for empty data returned from an import step within a flow:
function checkFTPSource (options) {
var errorMessage = '';
if(options.data === null) {
errorMessage = 'data is NULL';
}else if (options.data.length === 0) {
errorMessage = 'No files in source FTP location!';
}
var errorsArray = options.errors;
if (errorMessage.length > 0) {
const error = {code:1, message: errorMessage, source:'checkFTPSource'};
errorsArray.push(error);
}
return {
data: options.data,
errors: errorsArray
}
}
Configure this script in an export hook:
For more information on hooks, see Hooks for integrator.io.
Comments
0 comments
Please sign in to leave a comment.