diff --git a/.gitignore b/.gitignore index 987fe56..8ed8e15 100644 --- a/.gitignore +++ b/.gitignore @@ -116,4 +116,5 @@ documents.json documents-copy.json documents-done.json documents-error.json +documents-original.json rapport.txt diff --git a/index.js b/index.js index 31d7712..df3c03b 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ } } catch (error) { logger('error', ['index', 'document', _id, 'student', student, 'teacher', teacher, 'lookup student', error]) - documentsError.push({ document, success: false, error: error }) + documentsError.push({ document, success: false, error: error.message }) await writeFile('data/documents-error.json', JSON.stringify(documentsError, null, 2), 'utf-8') } } diff --git a/lib/get-tjommi-data.js b/lib/get-tjommi-data.js index fb74cb5..8f9fbed 100644 --- a/lib/get-tjommi-data.js +++ b/lib/get-tjommi-data.js @@ -13,10 +13,14 @@ module.exports = async options => { logger('info', ['lib', 'get-tjommi-data', 'student', student, 'teacher', teacher, 'success']) if (data.length === 1) { return data[0] - } else { + } else if (data.length > 0) { const errorMessage = 'too many matches' logger('error', ['lib', 'get-tjommi-data', 'student', student, 'teacher', teacher, errorMessage]) throw new Error(errorMessage) + } else if (data.length === 0) { + const errorMessage = 'student not found' + logger('error', ['lib', 'get-tjommi-data', 'student', student, 'teacher', teacher, errorMessage]) + throw new Error(errorMessage) } } catch (error) { logger('error', ['lib', 'get-tjommi-data', 'student', student, 'teacher', teacher, error])