Comments (12)
Can you show me the code you're running?
On Sat, Nov 5, 2016, 11:24 AM bunuble [email protected] wrote:
So I am making a bot using your API wrapper and I tried using a try except
to deal with the groupy.api.errors.ApiError but it still gets through and
crashes the bot. Any way to deal with this?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#29, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABrRTjEOe28nqoSg1TyYnn6EPwuSNIFMks5q7J_CgaJpZM4KqSnm
.
from groupy.
Traceback (most recent call last):
File "ddgbot.py", line 45, in <module>
mentions = active_group.messages().newest.attachments
File "/usr/lib/python3.5/site-packages/groupy/object/responses.py", line 138, in messages
raise e
File "/usr/lib/python3.5/site-packages/groupy/object/responses.py", line 126, in messages
since_id=since, after_id=after)
File "/usr/lib/python3.5/site-packages/groupy/api/endpoint.py", line 303, in index
return cls.response(r)
File "/usr/lib/python3.5/site-packages/groupy/api/endpoint.py", line 73, in response
raise errors.ApiError(data['meta'])
groupy.api.errors.ApiError: {'errors': ['read tcp 10.81.196.60:38811->10.79.182.137:22121: i/o timeout'], 'code': 500}
This is the Traceback
message = active_group.messages().newest
mentions = active_group.messages().newest.attachments
These are the two lines the error can happen. The line that causes it to happen is random.
I wrapped my code in this so I can see the error but the program still crashes. The methods to get the newest message and its attachments are within the try block
try:
[code]
except(KeyboardInterreupt,SystemExit)
raise
except:
[printing out error]
from groupy.
Well, the API seems to be returning a 500 error, which is why the exception
is raised. It seems like you're able to catch the exception just fine...
what do you mean by "still gets through and crashes the bot?"
On Sat, Nov 5, 2016, 12:09 PM bunuble [email protected] wrote:
Traceback (most recent call last):
File "ddgbot.py", line 45, in
mentions = active_group.messages().newest.attachments
File "/usr/lib/python3.5/site-packages/groupy/object/responses.py", line 138, in messages
raise e
File "/usr/lib/python3.5/site-packages/groupy/object/responses.py", line 126, in messages
since_id=since, after_id=after)
File "/usr/lib/python3.5/site-packages/groupy/api/endpoint.py", line 303, in index
return cls.response(r)
File "/usr/lib/python3.5/site-packages/groupy/api/endpoint.py", line 73, in response
raise errors.ApiError(data['meta'])
groupy.api.errors.ApiError: {'errors': ['read tcp 10.81.196.60:38811->10.79.182.137:22121: i/o timeout'], 'code': 500}This is the Traceback
message = active_group.messages().newest
mentions = active_group.messages().newest.attachmentsThese are the two lines the error can happen. The line that causes it to
happen is random.I wrapped my code in this so I can see the error but the program won't
crashtry:
[code]except(KeyboardInterreupt,SystemExit)
raiseexcept:
[printing out error]—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
#29 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABrRTiNMgRSTocAA2s6TkOcEKGzwl81tks5q7Ko7gaJpZM4KqSnm
.
from groupy.
It was a running process then it crashes. I check the output file and that was the last thing that happened before the process was terminated.
from groupy.
Then it sounds like maybe you're not catching and handling the ApiErrors
that get raised. If you catch the exception then your process should not
crash.
On Sat, Nov 5, 2016, 4:57 PM bunuble [email protected] wrote:
It was a running process then it crashes. I check the output file and that
was the last thing that happened before the process was terminated.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
#29 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABrRTqAL2tEjlVodBRvfcdqc5-k-rgoRks5q7O3CgaJpZM4KqSnm
.
from groupy.
How would I catch that specific ApiError? I tried except(groupy.api.erros.ApiError)
but I don't think that is right.
from groupy.
That should be correct, although you don't need the parentheses. Just make
sure you're putting the try-except around the right code (there may be
multiple places, mind you).
On Sun, Nov 6, 2016, 1:47 PM bunuble [email protected] wrote:
How would I catch that specific ApiError? I tried
except(groupy.api.erros.ApiError) but I don't think that is right.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
#29 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABrRTlXj7C9PgGqQlo0Zy3cQBvBisAXJks5q7iDNgaJpZM4KqSnm
.
from groupy.
I just reread this thread top to bottom. It occurs to me that you may be raising the exception that you catch (judging by the naked raise in the except block in your second post). If that's the case, remove the raise from the except block and you should be good (as in the exception won't crash your bot).
from groupy.
Did you ever get your issue resolved?
from groupy.
Yes. Your advice helped. Thanks a lot!
from groupy.
I got another quick question. What do I put so I can do something with generic attachments? Like for example, I can do if m.type == 'image'
, I can have a conditional so i can do something with images. I tried if m.type == 'GenericAttachment'
and if m.type == 'genericattachment
but it is not working
from groupy.
Sorry I'm just now reading this!
The idea of a GenericAttachment
is that it's type
attribute is something other than one of the currently known attachment types. So, for example, suppose next week they add the ability to have a video attachment. Well, all of a sudden their API is returning attachments with type "video" so until I wrote a VideoAttachment
class it would simply be a GenericAttachment
with a type
attribute of "video". Hope that makes sense.
I'm going to close this issue now, but feel free to reach out with any questions you may have.
from groupy.
Related Issues (20)
- attachments module: import errors, not serializable HOT 3
- Mentions not serializing on Post method HOT 6
- Mentions not serializing when posting from a Bot HOT 1
- API Key should not rely on global module-level variable HOT 17
- Recieve is spelled Receive
- Can't install even when Pillow is installed HOT 5
- authorization error.. anyone else? HOT 2
- Can't send messages to a chat? HOT 9
- potential parsing error on large groups HOT 2
- Like comments in a group without conversation_id? HOT 2
- Get 'likes' stats on a particular message HOT 2
- Gallery call crashes when shared Documents are in Gallery HOT 8
- API Token Validation HOT 2
- Issue with groups containing emoji in group name HOT 2
- Can't create multiple bots with no callback url HOT 6
- Adding to a group with user-id
- Adding by user id issue HOT 1
- Issue retreiving current location attachment
- How to Reply to Messages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from groupy.