Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String: add debugging message in case of allocation failure #8779

Closed
d-a-v opened this issue Dec 31, 2022 · 3 comments · Fixed by #8821
Closed

String: add debugging message in case of allocation failure #8779

d-a-v opened this issue Dec 31, 2022 · 3 comments · Fixed by #8821

Comments

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 31, 2022

Following this comment

Change would be there

Cc: @MacDada

@d-a-v d-a-v self-assigned this Dec 31, 2022
@d-a-v d-a-v added this to the 3.1 milestone Dec 31, 2022
@MacDada
Copy link

MacDada commented Dec 31, 2022

Wow, I did not expect there would be a response o.O Thanks and good luck! <3

@MacDada
Copy link

MacDada commented Dec 31, 2022

Change would be there

Out of curiosity: what kind of change do you have in mind?

  1. From my perspective, the best option would be an exception.
  • + Simple to detect problem, easy to handle "globally".
  • - But there can not be any exceptions on Arduino :/
  1. Second option is to make replace return bool to signal if it was successful.
  • + Clear interface
  • - Could be a little bit backwards incompatible (interface change), but since it returns void now, probably nobody really "checks" what it returns RN, so for the new code anybody can just start checking.
  • - Check and and handle each and every time it is used might be cumbersome
  1. Another way is to add a third parameter to replace: a reference bool to check if succeeded
  • + more BC than above
  • - even more cumbersome than above (having to create a var in advance on usage)
  1. Log info to serial
  • - You have to be lucky to observe serial monitor and notice
  • + But actually that's the first thing I do when there is a problem: log to serial everything I suspect might be connected to the issue -> so it would have helped me to spot the problem much faster
  1. Any other ideas?

EDIT: OK, NVM, I just noticed the issue's title xD So, it will be option 4. Alright, a compromise it is ;-)

@d-a-v d-a-v modified the milestones: 3.1, 4.0.0 Jan 6, 2023
@d-a-v
Copy link
Collaborator Author

d-a-v commented Jan 7, 2023

Yes, I think a message in debugging mode is the best we can do when exceptions are not enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants