Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Better way to get errors.  (Read 3251 times)

0 Members and 1 Guest are viewing this topic.

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Better way to get errors.
« on: December 02, 2014, 11:51:25 pm »
I would like to display sfml's errors in my gui but since they're an ostream theres really no neat way to do this....

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Better way to get errors.
« Reply #1 on: December 03, 2014, 12:14:58 am »
You can redirect the buffer as shown in the documentation (and told on IRC).
If you're don't know how to deal with the buffer once you get it, then you should read up on C++. ;)

Besides that, different error handling systems have been discussed back and forth many times, so there's no need to open yet another thread about it. Use the search function if you want to find them.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Better way to get errors.
« Reply #2 on: December 03, 2014, 12:36:31 am »
buffers and message boxes don't play nice. Even if I after I jump through hoops converting the error back to a string i get all the errors not one its garbage setup.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Better way to get errors.
« Reply #3 on: December 03, 2014, 12:45:04 am »
...i get all the errors not one its garbage setup.
No idea what you're trying to say here...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Better way to get errors.
« Reply #4 on: December 03, 2014, 12:53:03 am »
its a stream of errors. even if I redirect the errors theres no neat way to get a specific one.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Better way to get errors.
« Reply #5 on: December 03, 2014, 01:00:21 am »
Most of the code that can generate an error do have a direct way to test their error status (e.g. when loading a file you can check the returned bool), thus you should capture the error at a higher level and then directly process the error message, that way you should be able to get the matching error.
If you get multiple errors, you can easily split them per line, but yes it won't be as easy to connect the error to a specific event and filtering might also be a bit more cumbersome, but that then really begs the question whether your way of handling things is really such a good idea.

As stated in all the other similar threads, there most likely won't be a change in error handling till SFML 3, since its a rather fundamental thing and thus will affect the current API, which in turn can't be broken till SFML 3. In the meantime you'll either have to deal with the current system, or go and change SFML's source yourself.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Better way to get errors.
« Reply #6 on: December 03, 2014, 01:33:38 am »
You can redirect the buffer as shown in the documentation
...
If you're don't know how to deal with the buffer once you get it, then you should read up on C++. ;)
This gave me something to read about  ;)

I jump through hoops converting the error back to a string
I may have misunderstood but can't you use a stringstream for that?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Better way to get errors.
« Reply #7 on: December 03, 2014, 08:53:57 am »
I jump through hoops converting the error back to a string
I may have misunderstood but can't you use a stringstream for that?

Exactly.  In my code, when I wanted to capture shader compiler errors, I just redirected SFML's error stream to a single stringstream object, and my main()'s try-catch block would print stringstream.str() after e.what().