Skip to content

Commit a5d1d45

Browse files
committed
error handling
1 parent ac107f5 commit a5d1d45

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

examples/simple/api/index.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def home():
2626
post_url=url_for('second_page', _external=True),
2727
button2='github',
2828
button2_action='link',
29-
button2_target='https://github.com/devinaconley/python-frames'
29+
button2_target='https://github.com/devinaconley/python-frames',
30+
button3='do not press'
3031
)
3132

3233

@@ -36,8 +37,8 @@ def second_page():
3637
msg = message()
3738
print(f'received frame message: {msg}')
3839

39-
if msg.untrustedData.fid == 123:
40-
e = error('user 123 is not allowed!')
40+
if msg.untrustedData.buttonIndex == 3:
41+
e = error('wrong button!')
4142
print(e)
4243
return e
4344

examples/simple/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# requirements.txt
2-
framelib~=0.0.4b4
2+
framelib~=0.0.4b5
33
Flask~=3.0.1
44
pydantic
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# requirements.txt
2-
framelib~=0.0.4b3
2+
framelib~=0.0.4b5
33
Flask~=3.0.1
44
pydantic

framelib/hub.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ def get_message(
2424
auth = None
2525
if username:
2626
auth = (username, password)
27+
2728
res = requests.post(url, headers=headers, auth=auth, data=bytes.fromhex(msg))
2829

30+
if res.status_code != 200:
31+
raise ValueError(f'failed request to hub: {res.text}')
2932
body = res.json()
3033
if not body['valid']:
3134
raise ValueError('frame action message is invalid')
35+
3236
action = ValidatedMessage(**body['message'])
3337

3438
return action

framelib/neynar.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ def get_frame_message(msg: str, api_key: str) -> NeynarValidatedMessage:
2626
'api_key': api_key,
2727
'content-type': 'application/json'
2828
}
29+
2930
res = requests.post(url, json=body, headers=headers)
3031

32+
if res.status_code != 200:
33+
raise ValueError(f'failed request to neynar: {res.text}')
3134
body = res.json()
3235
if not body['valid']:
3336
raise ValueError('frame action message is invalid')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='framelib',
8-
version='0.0.4b4',
8+
version='0.0.4b5',
99
author='Devin A. Conley',
1010
author_email='[email protected]',
1111
description='lightweight library for building farcaster frames using python and flask',

0 commit comments

Comments
 (0)