Skip to content

Commit de55753

Browse files
committed
refactor warning checkExtracolumns
1 parent 096cd5d commit de55753

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

src/saveEventsFile.m

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,20 +284,28 @@ function printHeaderExtraColumns(logFile)
284284

285285
logFile(iEvent).(namesExtraColumns{iExtraColumn}) = data;
286286

287-
if ~ischar(data) && any(isnan(data)) && cfg.verbose > 0
288-
warning('saveEventsFile:missingData', ...
289-
'Missing some %s data for this event.', namesExtraColumns{iExtraColumn});
287+
if ~ischar(data) && cfg.verbose > 0
288+
289+
warningMessage = [];
290+
291+
if any(isnan(data))
292+
warningMessage = sprintf( ...
293+
'Missing some %s data for this event.', ...
294+
namesExtraColumns{iExtraColumn});
295+
296+
elseif all(isnan(data))
297+
warningMessage = sprintf( ...
298+
'Missing %s data for this event.', ...
299+
namesExtraColumns{iExtraColumn});
290300

291-
if cfg.verbose > 1
292-
disp(logFile(iEvent));
293301
end
294302

295-
elseif ~ischar(data) && all(isnan(data)) && cfg.verbose > 0
296-
warning('Missing %s data for this event.', namesExtraColumns{iExtraColumn});
303+
warningSaveEventsFile('missingData', warningMessage);
297304

298305
if cfg.verbose > 1
299306
disp(logFile(iEvent));
300307
end
308+
301309
end
302310

303311
end
@@ -507,6 +515,21 @@ function errorSaveEventsFile(identifier)
507515
error(errorStruct);
508516
end
509517

518+
function warningSaveEventsFile(identifier, warningMessage)
519+
520+
if nargin == 2 && ~isempty(identifier) && ~isempty(warningMessage)
521+
522+
switch identifier
523+
case ''
524+
525+
end
526+
527+
warningMessageID = ['saveEventsFile:' identifier];
528+
warning(warningMessageID, warningMessage);
529+
530+
end
531+
end
532+
510533
function talkToMe(cfg, logFile)
511534

512535
if cfg.verbose > 0

0 commit comments

Comments
 (0)