Skip to content

Commit 279aacc

Browse files
committed
chapter 02: returns error if the filename is empty
1 parent bb97e1e commit 279aacc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ArgumentError extends Error {}
2+
3+
module.exports = ArgumentError;

chapter_02-a-first-unit-test/LogAn/logAnalyzer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
const ArgumentError = require('./ArgumentError');
2+
13
function logAnalyzer() {
24
/**
35
* @param {string} fileName
46
* @return {boolean}
57
*/
68
function isValidLogFileName(fileName) {
9+
if (fileName === '') {
10+
throw new ArgumentError('filename has to be provided');
11+
}
12+
713
if (!fileName.toUpperCase().endsWith('.SLF')) {
814
return false;
915
}

0 commit comments

Comments
 (0)