Skip to content

Commit

Permalink
More error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertyquerty committed Apr 30, 2018
1 parent 3f16d33 commit 4cdb83b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 26 deletions.
Binary file added dist/pypresence-1.0.9.tar.gz
Binary file not shown.
10 changes: 0 additions & 10 deletions pypresence.egg-info/PKG-INFO

This file was deleted.

11 changes: 0 additions & 11 deletions pypresence.egg-info/SOURCES.txt

This file was deleted.

1 change: 0 additions & 1 deletion pypresence.egg-info/dependency_links.txt

This file was deleted.

1 change: 0 additions & 1 deletion pypresence.egg-info/top_level.txt

This file was deleted.

5 changes: 4 additions & 1 deletion pypresence/client.py
Expand Up @@ -38,7 +38,10 @@ def read_output(self):
except BrokenPipeError:
raise InvalidID
code, length = struct.unpack('<ii', data[:8])
return json.loads(data[8:].decode('utf-8'))
payload = json.loads(data[8:].decode('utf-8'))
if payload["evt"] == "ERROR":
raise ServerError(payload["data"]["message"])
return payload


def send_data(self, op: int, payload: dict):
Expand Down
6 changes: 5 additions & 1 deletion pypresence/exceptions.py
@@ -1,7 +1,11 @@
class InvalidID(Exception):
def __init__(self):
super().__init__('Client ID is Invalid')

class InvalidPipe(Exception):
def __init__(self):
super().__init__('Pipe Not Found - Is Discord Running?')

class ServerError(Exception):
def __init__(self,message):
super().__init__(message.replace(']','').replace('[','').capitalize())
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -3,7 +3,7 @@
setup(name='pypresence',
author='qwertyquerty',
url='https://github.com/qwertyquerty/pypresence',
version='1.0.7',
version='1.0.9',
packages=['pypresence'],
license='MIT',
description='Discord RPC client written in python',
Expand Down

0 comments on commit 4cdb83b

Please sign in to comment.