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
dedi-api: Exception Classes
Moderator: NADEO
-
- Posts: 1026
- Joined: 15 Jun 2010, 15:46
Re: dedi-api: Exception Classes
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? ^^
- 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
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
Re: dedi-api: Exception Classes
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
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
Re: dedi-api: Exception Classes
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: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)
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
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)
-
- Posts: 1026
- Joined: 15 Jun 2010, 15:46
Re: dedi-api: Exception Classes
Indeed, the team mode example isn't convincing
However:
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.

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 ^^steeffeen wrote:- to prevent this you would have to check again if the player is still on the server
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
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
Re: dedi-api: Exception Classes
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
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
-
- Posts: 1026
- Joined: 15 Jun 2010, 15:46
Re: dedi-api: Exception Classes
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
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
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
Who is online
Users browsing this forum: No registered users and 1 guest