Git Product home page Git Product logo

Comments (12)

rhgrant10 avatar rhgrant10 commented on July 21, 2024

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.

nithjino avatar nithjino commented on July 21, 2024
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.

rhgrant10 avatar rhgrant10 commented on July 21, 2024

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.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 won't
crash

try:
[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.

nithjino avatar nithjino commented on July 21, 2024

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.

rhgrant10 avatar rhgrant10 commented on July 21, 2024

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.

nithjino avatar nithjino commented on July 21, 2024

How would I catch that specific ApiError? I tried except(groupy.api.erros.ApiError) but I don't think that is right.

from groupy.

rhgrant10 avatar rhgrant10 commented on July 21, 2024

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.

rhgrant10 avatar rhgrant10 commented on July 21, 2024

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.

rhgrant10 avatar rhgrant10 commented on July 21, 2024

Did you ever get your issue resolved?

from groupy.

nithjino avatar nithjino commented on July 21, 2024

Yes. Your advice helped. Thanks a lot!

from groupy.

nithjino avatar nithjino commented on July 21, 2024

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.

rhgrant10 avatar rhgrant10 commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.