Transfer of Exceptions

Options
vitorcmaia
edited January 2013 in Photon Server
In case of exceptions and errors on the server side code, I want to send the information about them to the client. Only the information about the specific problem, nothing more than that. Could be just a string. Should I send an Operation Response in every "catch" of my server code, or is there a native functionality to handle this? I'm afraid of the fibers too. Will my exception information be sent, or will the priority queue in the fiber make my error not be sent?

Comments

  • dreamora
    Options
    you should not see any exceptions as an exception in server side code is basically deadly.
    Instead you should properly handle this kind of situation.

    If you do that you can then also use operations / events to inform the desired client about it.
    An operation response can be used too but only if you want to send informations to the operation requesting client.
  • Thanks for your help dreamora, as always :)

    There's not much to add - of course, you can wrap the code for your operations in a try / catch block and send an operation response with an error message to the client from the catch block. (Yes, the operation response will be sent.).

    For exceptions that don't happen during an operation request (for example, on timer callbacks etc.), you would need to raise an event for all affected players... but keep in mind that exceptions are "expensive", you should not misuse them to pass information around (simple example: don't throw an exception if you implement some authentication and the client sends incorrect credentials; it's better to define return values etc.). Exceptions should only happen in case of programming errors (which should hopefully not happen in the first place. ;))