-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaaa.py
More file actions
52 lines (32 loc) · 1.14 KB
/
aaa.py
File metadata and controls
52 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from datetime import datetime, timedelta
import pytz
import os.path
import time
import argparse
from httplib2 import Response
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
def test():
content = '{"error": {"message": "An error occurred"}}' # example JSON content
try:
content = '{"error": {"message": "An error occurred"}}'.encode('utf-8')
# Create a mock response object using httplib2.Response
status_code = 500
reason = 'Internal Server Error'
# Mock response object
resp = Response({'status': status_code, 'reason': reason})
# Raising the HttpError with the correct response object and content
raise HttpError(resp=resp, content=content)
#raise HttpError(resp={}, content=content)
except HttpError as error:
print(f"An error aaa occurred: {error}")
def main():
try:
test()
except HttpError as error:
print(f"An error occurred: {error}")
if __name__ == "__main__":
main()