From a8d1ce04a35d351a12e219171744fa8a6fd32928 Mon Sep 17 00:00:00 2001 From: Alexius Wadell Date: Sun, 29 Jan 2017 20:41:13 -0500 Subject: [PATCH] Added try catch loop to update check code Intended to prevent unforseen failures crashing datamaster If unable to update -> Stops trying to prevent user annoyance --- @Datamaster/Datamaster.m | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/@Datamaster/Datamaster.m b/@Datamaster/Datamaster.m index 8049371..6e0d360 100644 --- a/@Datamaster/Datamaster.m +++ b/@Datamaster/Datamaster.m @@ -35,28 +35,35 @@ %% Check for Updates - But Only once per session persistent flagChecked if isempty(flagChecked) - %Move to the Datamaster folder - savedCd = cd; cd(Datamaster.getPath); + try + %Move to the Datamaster folder + savedCd = cd; cd(Datamaster.getPath); - %Fetch updates from remote - [success, ~] = system('git fetch'); - assert(success==0, 'Error fetching updates from remote'); + %Fetch updates from remote + [success, ~] = system('git fetch'); + assert(success==0, 'Error fetching updates from remote'); - %Check Current Status - [success, str] = system('git status'); - assert(success==0, 'Error reading git repo status'); + %Check Current Status + [success, str] = system('git status'); + assert(success==0, 'Error reading git repo status'); - %Get status - status = regexpi(str, 'Your branch is behind ''(.+)'' by (\d+)', 'tokens'); - - %Report to user - if ~isempty(status) - warning(['Updates are avaliable. ',... - 'Run Datamaster Setup to Update']); + %Get status + status = regexpi(str, 'Your branch is behind ''(.+)'' by (\d+)', 'tokens'); + + %Report to user + if ~isempty(status) + warning(['Updates are avaliable. ',... + 'Run Datamaster Setup to Update']); + end + + %Return to original directory + cd(savedCd); flagChecked = true; + catch + %Warn user that we were unable to check for updates but + %don't recheck this session + warning('Unable to check for updates'); + flagChecked = true; end - - %Return to original directory - cd(savedCd); flagChecked = true; end end