dedi-api: Exception Classes

Discuss the Dedicated Server Tools developed by Nadeo Live such as ManiaLive, Trust Circles, Dedicated Manager, Competition Manager and Lobbies

Moderator: NADEO

User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

dedi-api: Exception Classes

Post by steeffeen »

Hey there,

I would like you to take a look at this draft for exception classes based on the fault messages.
https://github.com/ManiaControl/dedicat ... 778e3b6586

If each error message has its own class then you can explicitly catch them and don't need to compare the strings on all the possible occurrences.
Maybe it can be integrated in the official version? For that I would complete it if required.

Feedback welcome!

Thanks in advance,
Steff
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    The_Big_Boo
    Posts: 1026
    Joined: 15 Jun 2010, 15:46

    Re: dedi-api: Exception Classes

    Post by The_Big_Boo »

    It seems like an interesting idea but I have some doubts.

    - I'm not sure if doing the complete list is really useful.
    I mean, it is useful if the number of different fault messages the dedicated can send is like a dozen but if it's more like a hundred, then only the most common ones should have their own class thus a hard question: how to choose them?

    - Do these faults happen often enough?
    From my experience, they're quite rare (partly because the Connection class is already checking arguments to avoid most of them) and come most of the time from programming mistakes, thus they disappear after debugging. For instance, the unkown (typo is a private joke) login fault should never happen.


    I'm not against (it's not a big deal to add them), but do you have some real use cases so I can clearly see why it's a must-have? ^^
    OS: Win 7 Pro x64
    RAM: 2x4GB Corsair @ 1600MHz
    CPU: Intel i5 760 @ 3.6GHz
    Mobo: Asus P7P55D-E
    GPU: NVidia GTX 760 2GB
    HDD: WD Black 1TB
    Sound: VIA VT1828S (onboard)
    Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: dedi-api: Exception Classes

    Post by steeffeen »

    well that's not the best example ^^
    i would rather like to describe the following situation:
    - you display a player list with buttons for actions regarding each player
    - one of these players leaves the server, now you get the "unknown login" error if an action for him is triggered
    - to prevent this you would have to check again if the player is still on the server
    - the player could have been removed from the playerlist between the check and the action (very unlikely but still possible i would think), again error
    - so the check beforehands makes sense but can't prevent the exception completely

    so it's not only caused by programming issues imo
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      User avatar
      steeffeen
      Translator
      Translator
      Posts: 2463
      Joined: 14 Oct 2012, 16:22
      Location: Germany

      Re: dedi-api: Exception Classes

      Post by steeffeen »

      to add:
      you're right that not every error message needs an own class
      though it would be great if one could distinguish between player related, script related or connection errors etc.
      like you said it's hard to determine which errors deserve an own exception

      a good alternative would be adding actual error codes
      maybe similar to http error codes:

      Code: Select all

      1xx connection
      2xx configuration
      3xx script
      4xx map
      5xx player
      etc.

      though it might be complex to classify the errors
      one could think a "Too many players." error would relate to players while i would put it into configuration (~server setting)
        Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

        ManiaControl, FancyManiaLinks
        The_Big_Boo
        Posts: 1026
        Joined: 15 Jun 2010, 15:46

        Re: dedi-api: Exception Classes

        Post by The_Big_Boo »

        Indeed, the team mode example isn't convincing :D However:
        steeffeen wrote:- to prevent this you would have to check again if the player is still on the server
        If the player has left, you should have been warned already by the server so if you track who's connected, it takes a nanosecond to check. The player can still left between the time you click on the action and the time the dedicated receives the command from your controller but this timespan is so short, it's indeed very unlikely to happen. Has anyone ever encountered this case? You still made a point though ^^


        About your http-like error codes: it could only be done in the dedicated itself, else it means knowing the complete list of fault messages (good luck with that). And I think it's best anyway to keep the fault codes sent by the dedicated instead of overriding them with custom ones.
        OS: Win 7 Pro x64
        RAM: 2x4GB Corsair @ 1600MHz
        CPU: Intel i5 760 @ 3.6GHz
        Mobo: Asus P7P55D-E
        GPU: NVidia GTX 760 2GB
        HDD: WD Black 1TB
        Sound: VIA VT1828S (onboard)
        Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
        User avatar
        steeffeen
        Translator
        Translator
        Posts: 2463
        Joined: 14 Oct 2012, 16:22
        Location: Germany

        Re: dedi-api: Exception Classes

        Post by steeffeen »

        yeah my suggestion was regarding the dedicated itself
        currently pretty much all errors have the code -1000 which isn't helpful at all ^^
        i didn't mean to set the error codes in php, sorry if it was misleading
          Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

          ManiaControl, FancyManiaLinks
          The_Big_Boo
          Posts: 1026
          Joined: 15 Jun 2010, 15:46

          Re: dedi-api: Exception Classes

          Post by The_Big_Boo »

          Oh, alright then ^^

          Anyway, I more or less merged your fork of dedicated-api in mine (https://github.com/NewboO/dedicated-server-api) which, I hope, will replace the current one. So you can make pull requests here if you like ;)
          OS: Win 7 Pro x64
          RAM: 2x4GB Corsair @ 1600MHz
          CPU: Intel i5 760 @ 3.6GHz
          Mobo: Asus P7P55D-E
          GPU: NVidia GTX 760 2GB
          HDD: WD Black 1TB
          Sound: VIA VT1828S (onboard)
          Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
          Post Reply

          Return to “Dedicated Server Tools”

          Who is online

          Users browsing this forum: No registered users and 2 guests