Skip to content

Commit

Permalink
Improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Aug 21, 2022
1 parent 0251652 commit a960c47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ def find_orphans(self):
return orphanedaddon, orphaneconfig

def search(self, query):
if self.config['WAAAPIKey'] == '':
raise RuntimeError('This feature requires the Wago Addons API key.\n'
'It can be obtained here: https://addons.wago.io/patreon')
results = []
payload = requests.get(f'https://addons.wago.io/api/external/addons/_search?query={quote_plus(query.strip())}'
f'&game_version={self.clientType}', headers=HEADERS,
Expand Down Expand Up @@ -546,6 +549,9 @@ def create_reg(self):
'@="\\"' + os.path.abspath(sys.executable).replace('\\', '\\\\') + '\\" \\"%1\\""')

def parse_wagoapp_payload(self, url):
if self.config['WAAAPIKey'] == '':
raise RuntimeError('This feature requires the Wago Addons API key.\n'
'It can be obtained here: https://addons.wago.io/patreon')
projectid = url.replace('wago-app://addons/', '')
payload = requests.get(f'https://addons.wago.io/api/external/addons/{projectid}?game_version='
f'{self.clientType}', headers=HEADERS,
Expand Down Expand Up @@ -618,6 +624,9 @@ def detect_accounts(self):

# noinspection PyTypeChecker
def detect_addons(self):
if self.config['WAAAPIKey'] == '':
raise RuntimeError('This feature requires the Wago Addons API key.\n'
'It can be obtained here: https://addons.wago.io/patreon')
names = []
namesinstalled = []
slugs = []
Expand Down
3 changes: 3 additions & 0 deletions CB/WagoAddons.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def __init__(self, url, checkcache, clienttype, allowdev, apikey):
self.payload['display_name'] = self.payload['name']
self.payload['recent_release'] = self.payload['recent_releases']
else:
if self.apiKey == '':
raise RuntimeError(f'{url}\nThe Wago Addons API key is missing. '
f'It can be obtained here: https://addons.wago.io/patreon')
try:
self.payload = requests.get(f'https://addons.wago.io/api/external/addons/{project}?game_version='
f'{self.clientType}', headers=HEADERS, auth=APIAuth('Bearer', self.apiKey),
Expand Down
2 changes: 1 addition & 1 deletion CB/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
from rich.terminal_theme import TerminalTheme

__version__ = '4.2.0'
__version__ = '4.2.1'
__license__ = 'GPLv3'
__copyright__ = '2019-2022, Paweł Jastrzębski <pawelj@iosphe.re>'
__docformat__ = 'restructuredtext en'
Expand Down

0 comments on commit a960c47

Please sign in to comment.