Skip to content

Commit b77d516

Browse files
committed
dotnet_* try-catch for simplicity
1 parent 02296c1 commit b77d516

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

+stdlib/dotnet_version.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
function v = dotnet_version()
44

5-
vs = System.Environment.Version;
6-
7-
v = sprintf('%d.%d.%d', vs.Major, vs.Minor, vs.Build);
5+
try
6+
vs = System.Environment.Version;
7+
v = sprintf('%d.%d.%d', vs.Major, vs.Minor, vs.Build);
8+
catch
9+
v = '';
10+
end
811

912
end

+stdlib/has_dotnet.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66
function y = has_dotnet()
77

88
try
9-
y = (ispc() || ~isMATLABReleaseOlderThan('R2024b')) && NET.isNETSupported;
10-
catch e
11-
switch e.identifier
12-
case {'MATLAB:scriptNotAFunction', 'MATLAB:undefinedVarOrClass', 'Octave:undefined-function'}
13-
y = false;
14-
otherwise, rethrow(e)
15-
end
9+
y = NET.isNETSupported;
10+
catch
11+
y = false;
1612
end
1713

1814
end

0 commit comments

Comments
 (0)