Skip to content

Commit

Permalink
fixed bug in keeping error state (since error does not return), added…
Browse files Browse the repository at this point in the history
… it to test script
  • Loading branch information
robertoostenveld committed Jun 21, 2017
1 parent 48d8471 commit 388164a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 20 additions & 1 deletion test/test_notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,26 @@
sublevel(@ft_info)
sublevel(@ft_notice)
sublevel(@ft_warning)
% sublevel(@ft_error)
% sublevel(@ft_error) % this one cannot be tested the same way

try
ft_error('off'); % this should not make a difference
ft_error('something');
ok = false;
catch
me = ft_error('last');
assert(strcmp(me.message, 'something'))
assert(strcmp(me.identifier, 'FieldTrip:test_notification'))
ok = true;
end

if ~ok
error('ft_error failed');
else
fprintf('========================================\n')
fprintf('ft_error looks good\n');
fprintf('========================================\n')
end

function sublevel(notice)

Expand Down
4 changes: 3 additions & 1 deletion utilities/private/ft_notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@
if strcmp(msgState, 'on')

if strcmp(level, 'error')
% this is fully handled by the ERROR function
% update the global variable
ft_default.notification.(level) = s;
% the remainder is fully handled by the ERROR function
error(msgId, varargin{:});

elseif strcmp(level, 'warning')
Expand Down

0 comments on commit 388164a

Please sign in to comment.