Unfortunately the documentation of serial does not explain what happens, if the port cannot be opened. Therefore I guess:
try
s_port=serial('COM6','BaudRate',115200,'Parity','none', ...
'DataBits',8,'FlowControl','none');
catch
errordlg(...)
return;
end
Or:
s_port = serial('COM6','BaudRate',115200,'Parity','none', ...
'DataBits',8,'FlowControl','none');
if isempty(s_port) % or what ever, please simply test this
errordlg(...)
return;
end