File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -732,6 +732,30 @@ from an object:
732732... Object.metadata.apply_atomic_operations( * [AVUOperation(operation = ' remove' , avu = i) for i in avus_on_Object] )
733733```
734734
735+ Extracting JSON encoded server information in case of error
736+ ---------------------------------------------------------- -
737+
738+ Some server apis, including atomic metadata and replica truncation, can fail for various reasons and generate an
739+ exception. In these cases the message object returned from the server is made available in the ' server_msg' attribute
740+ of the iRODSException object .
741+
742+ This enables an approach like the following, which logs server information possibly underlying the error that was evoked:
743+
744+ ```python
745+ try :
746+ Object.metadata.apply_atomic_operations( ops )
747+ # or:
748+ DataObject.replica_truncate( size )
749+ except iRODSException as exc:
750+ log.error(' Server API call failure. Traceback = %r ; iRODS Server info = %r ' ,
751+ traceback.extract_tb(sys.exc_info()[2 ]),
752+ exc.server_msg.get_json_encoded_struct())
753+ ```
754+
755+ For `DataObject.replica_truncate(... )` , note that exc.server_msg.get_json_encoded_struct() can be used in the exception- handling
756+ code path to retrieve the same information that would have been routinely returned from the truncate call itself, had it actually
757+ completed without error.
758+
735759Special Characters
736760------------------
737761
You can’t perform that action at this time.
0 commit comments