From 388164a0d5dba5bd333b28be609c56d0b9ffe32b Mon Sep 17 00:00:00 2001 From: Robert Oostenveld Date: Wed, 21 Jun 2017 17:04:15 +0200 Subject: [PATCH] fixed bug in keeping error state (since error does not return), added it to test script --- test/test_notification.m | 21 ++++++++++++++++++++- utilities/private/ft_notification.m | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/test/test_notification.m b/test/test_notification.m index 4032ae601d..98bb29f9cf 100644 --- a/test/test_notification.m +++ b/test/test_notification.m @@ -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) diff --git a/utilities/private/ft_notification.m b/utilities/private/ft_notification.m index 4f35ef3b16..2705d789e0 100644 --- a/utilities/private/ft_notification.m +++ b/utilities/private/ft_notification.m @@ -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')