forked from justinblaber/ncorr_2D_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncorr_util_wrapcallbacktrycatch.m
27 lines (25 loc) · 1.09 KB
/
ncorr_util_wrapcallbacktrycatch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function handle_wrapcallbacktrycatch = ncorr_util_wrapcallbacktrycatch(handle_callback,handle_figure)
% This function is a wrapper that wraps the callback in a try-catch
% statement. If an error is thrown after the figure handle is closed, then
% disregard the error; if not, then rethrow it. The reason for this function
% is that closing a figure always interrupts a function, which can cause it
% to throw an error. Make sure to only throw the error if the figure which
% the function is attached to is still open.
%
% Inputs -----------------------------------------------------------------%
% handle_callback - function handle;
% handle_figure - figure handle;
%
% Outputs ----------------------------------------------------------------%
% handle_wrapcallbacktrycatch - function handle;
handle_wrapcallbacktrycatch = @wrapcallbacktrycatch;
function wrapcallbacktrycatch(varargin)
try
handle_callback(varargin{:});
catch err
if (ishandle(handle_figure))
rethrow(err);
end
end
end
end