the-marenga / sf-api

Manage Shakes & Fidget characters via simple commands. Handles encryption, response parsing and everything else for you
MIT License
18 stars 3 forks source link

error message on starting quest #38

Closed tiquis0290 closed 6 months ago

tiquis0290 commented 8 months ago

i call this let response = session.send_command(&Command::StartQuest { quest_pos: (3), overwrite_inv: (true) }).await.unwrap(); anp got this err message called Result::unwrap() on an Err value: ServerError("adventure index must be 1-3") which is strongly unintuitive because the range is from 0-2, i'am not sure from where this error mesage goes, because i read that you are changing the values because of sfgame servers but i thing that this error message shouldnt be let as it is

the-marenga commented 8 months ago

Yeah, that is because the 1-3 error message is directly passes through from the server, which only sees the modified (+1) value, so 4 in that case. I still think modifying the passed in values is overall more beneficial, as you can just pass the index of stuff, instead of having +1 everywhere yourself, so I am not changing that, but I agree, that just passing through the error is also bad.

The best way forward would probably be to just to do bounds checks everywhere and return a custom error, instead of the server error. I tried to stay away from that until now to make sure I would not accidentaly introduce false errors, or change the meaning of errors (connection error -> out of bounds error), but yeah, those error messages are for sure guiding people in the wrong direction. I need to fix that for the next release, thanks for the report