Skip to content

Commit eeb9a71

Browse files
authored
Merge pull request #726 from Remi-Gau/fixes
[FIX] add more explicit error message for input parsing of getData
2 parents 91e3fed + 7e3f24f commit eeb9a71

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/IO/getData.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@
2525
addRequired(args, 'opt', @isstruct);
2626
addRequired(args, 'bidsDir', @isdir);
2727

28-
parse(args, varargin{:});
28+
try
29+
parse(args, varargin{:});
30+
catch ME
31+
if bids.internal.starts_with(ME.message, 'The value of ')
32+
msg = sprintf('The following directory does not exist:\n\t%s', varargin{2});
33+
errorHandling(mfilename(), 'notADirectory', msg, false);
34+
else
35+
rethrow(ME);
36+
end
37+
end
2938

3039
opt = args.Results.opt;
3140
bidsDir = args.Results.bidsDir;
@@ -64,7 +73,7 @@
6473
strjoin(opt.taskName), ...
6574
createUnorderedList(bids.query(BIDS, 'tasks')));
6675

67-
errorHandling(mfilename(), 'noMatchingTask', msg, false, opt.verbosity);
76+
errorHandling(mfilename(), 'noMatchingTask', msg, false);
6877

6978
end
7079

tests/tests_bids/test_getData.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
initTestSuite;
99
end
1010

11+
function test_getData_invalid_dir()
12+
13+
opt = struct([]);
14+
bidsDir = fullfile('/foo');
15+
16+
assertExceptionThrown(@()getData(opt, bidsDir), ...
17+
'getData:notADirectory');
18+
19+
end
20+
1121
function test_getData_error_no_matching_task()
1222

1323
opt = setOptions('dummy');

0 commit comments

Comments
 (0)