Skip to content

Commit b626c1f

Browse files
Update the readme
1 parent 65a0b1b commit b626c1f

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

README.md

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,44 +1082,26 @@ results = titanium_scale.upload_sample_and_get_results(
10821082
)
10831083
```
10841084

1085-
1086-
#### CloudDeepScan
1085+
#### Error handling
1086+
Each module raises corresponding custom exceptions according to the error status code returned in the response.
1087+
Custom exception classes that correspond to error status codes also carry the original response object in its entirety.
1088+
To learn how to fetch and use the response object out of the exception object, see the following examples.
10871089
```python
1088-
from ReversingLabs.SDK.clouddeepscan import CloudDeepScan, CloudDeepScanException
1090+
from ReversingLabs.SDK.ticloud import FileReputation
10891091

10901092

1091-
cloud_deep_scan = CloudDeepScan(
1092-
token_endpoint="https://exampletokenendpoint.reversinglabs.com/oauth2/token",
1093-
rest_hostname="https://example.clouddeepscan.com",
1094-
client_id="exampleclientid",
1095-
client_secret="exampleclientsecret"
1093+
file_rep = FileReputation(
1094+
host="https://data.reversinglabs.com",
1095+
username="u/username",
1096+
password="password"
10961097
)
1097-
try:
1098-
submission_id = cloud_deep_scan.upload_sample(sample_path="/path/to/file/suspicious_file.exe")
1099-
except CloudDeepScanException:
1100-
pass
1101-
1102-
try:
1103-
status_data = cloud_deep_scan.fetch_submission(submission_id=submission_id) # Returns CloudDeepScanSubmissionStatus instance
1104-
print(status_data.id) # submission id
1105-
print(str(status_data.created_at)) # datetime instance
1106-
print(status_data.status) # status
1107-
print(status_data.report) # URI path to the report file
1108-
except CloudDeepScanException:
1109-
pass
1110-
1111-
try:
1112-
submission_history = cloud_deep_scan.fetch_submission_history(sample_hash="0f5de47158e40b5d791cb3698b7dc599be21cf95")
1113-
for submission_status in submission_history:
1114-
print(submission_status.id) # submission id
1115-
print(str(submission_status.created_at)) # datetime instance
1116-
print(submission_status.status) # status
1117-
print(submission_status.report) # URI path to the report file
1118-
except CloudDeepScanException:
1119-
pass
11201098

11211099
try:
1122-
cloud_deep_scan.download_report(sample_hash="0f5de47158e40b5d791cb3698b7dc599be21cf95", report_output_path="reports/report1.json") # report parent directory must exist
1123-
except CloudDeepScanException:
1124-
pass
1100+
resp = file_rep.get_file_reputation(hash_input="cf23df2207d99a74fbe169e3eba035e633b65d94")
1101+
except Exception as e:
1102+
if hasattr(e, "response_object"):
1103+
print(e.response_object.content)
1104+
else:
1105+
raise
11251106
```
1107+
Same approach can also be used for A1000 and TitaniumScale.

0 commit comments

Comments
 (0)