Skip to content

Commit

Permalink
Better error reporting when a resource cannot be found.
Browse files Browse the repository at this point in the history
See #129
  • Loading branch information
hgrecco committed Mar 31, 2015
1 parent 8555fc1 commit 33aa8f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pyvisa/ctwrapper/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,9 @@ def parse_resource_extended(library, session, resource_name):
unaliased_expanded_resource_name,
alias_if_exists)

if ret != constants.VI_SUCCESS:
return None, ret

res = [buffer_to_text(val)
for val in (resource_class,
unaliased_expanded_resource_name,
Expand Down
2 changes: 1 addition & 1 deletion pyvisa/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ def resource_info(self, resource_name):
ret, err = self.visalib.parse_resource_extended(self.session, resource_name)
if err == constants.StatusCode.success:
return ret
raise ValueError('Could not parse resource: %s' % resource_name)
raise ValueError('Could not parse resource: %s (error code %s)' % (resource_name, ret))

def open_bare_resource(self, resource_name,
access_mode=constants.AccessModes.no_lock,
Expand Down

0 comments on commit 33aa8f3

Please sign in to comment.