-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageAnalysisErrorHandler.m
More file actions
84 lines (77 loc) · 2.72 KB
/
ImageAnalysisErrorHandler.m
File metadata and controls
84 lines (77 loc) · 2.72 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
classdef ImageAnalysisErrorHandler < handle
%IMAGEANALYSISERRORHANDLER Defines a class that allows for warnings and
%other errors to be passed to the user
properties
status %The error status
message %A message describing the error
end
properties(Constant,Hidden=true)
STATUS_OK = 'ok'; %Indicates that no error has occurred
STATUS_WARNING = 'warning'; %Indicates that a warning has occurred
STATUS_ERROR = 'error'; %Indicates that an error has occurred
end
methods
function self = ImageAnalysisErrorHandler(status,message)
%IMAGEANALYSISERRORHANDLER Creates an instance of the class
%
% ERR = IMAGEANALYSISERRORHANDLER() Creates a blank instance
%
% ERR = IMAGEANALYSISERRORHANDLER(S) Creates an instance with
% status S
%
% ERR = IMAGEANALYSISERRORHANDLER(S,M) Creates an instance
% with status S and message M
if nargin == 0
self.status = self.STATUS_OK;
self.message = '';
elseif nargin == 1
self.status = status;
self.message = '';
else
self.status = status;
self.message = message;
end
end
function self = copy(self,obj)
%COPY Copies properties of the class
%
% ERR = ERR.COPY(OBJ) Copies the properties from class
% instance OBJ to current instance ERR.
self.status = obj.status;
self.message = obj.message;
end
function r = ok(self)
%OK Returns true if no error or warning, false otherwise
%
% R = OK() Returns true if no error or warning, false
% otherwise
if strcmpi(self.status,self.STATUS_OK)
r = true;
else
r = false;
end
end
function r = warning(self)
%OK Returns true if warning, false otherwise
%
% R = WARNING() Returns true if warning, false
% otherwise
if strcmpi(self.status,self.STATUS_WARNING)
r = true;
else
r = false;
end
end
function r = error(self)
%OK Returns true if error, false otherwise
%
% R = ERROR() Returns true if error, false
% otherwise
if strcmpi(self.status,self.STATUS_ERROR)
r = true;
else
r = false;
end
end
end
end