File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
auto-instrumentation/+opentelemetry/+autoinstrument Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -159,10 +159,17 @@ function processFileInput(f)
159159f = string(f ); % force into a string
160160if startsWith(f , ' @' ) % check for anonymous function
161161 error(" opentelemetry:autoinstrument:AutoTrace:AnonymousFunction" , ...
162- f + " is an anonymous function and is not supported." );
162+ replace( f , " \ " , " \\ " ) + " is an anonymous function and is not supported." );
163163end
164- if exist(f , " file" ) ~= 2
165- error(" opentelemetry:autoinstrument:AutoTrace:InvalidMFile" , ...
166- f + " is not found or is not a valid MATLAB file with a .m extension." )
164+ [~ ,~ ,fext ] = fileparts(f ); % check file extension
165+ filetype = exist(f , " file" ); % check file type
166+ if ~(filetype == 2 && ismember(fext , [" " " .m" " .mlx" ]))
167+ if exist(f , " builtin" )
168+ error(" opentelemetry:autoinstrument:AutoTrace:BuiltinFunction" , ...
169+ replace(f , " \" , " \\" ) + " is a builtin function and is not supported." );
170+ else
171+ error(" opentelemetry:autoinstrument:AutoTrace:InvalidMFile" , ...
172+ replace(f , " \" , " \\" ) + " is not found or is not a valid MATLAB file with a .m or .mlx extension." );
173+ end
167174end
168175end
Original file line number Diff line number Diff line change @@ -242,7 +242,10 @@ function testInvalidInputFunction(testCase)
242242 verifyError(testCase , @()opentelemetry .autoinstrument .AutoTrace(@()example1 ), " opentelemetry:autoinstrument:AutoTrace:AnonymousFunction" );
243243
244244 % builtin function
245- verifyError(testCase , @()opentelemetry .autoinstrument .AutoTrace(@uplus ), " opentelemetry:autoinstrument:AutoTrace:InvalidMFile" );
245+ verifyError(testCase , @()opentelemetry .autoinstrument .AutoTrace(@uplus ), " opentelemetry:autoinstrument:AutoTrace:BuiltinFunction" );
246+
247+ % nonexistent function
248+ verifyError(testCase , @()opentelemetry .autoinstrument .AutoTrace(@bogus ), " opentelemetry:autoinstrument:AutoTrace:InvalidMFile" );
246249 end
247250 end
248251end
You can’t perform that action at this time.
0 commit comments