SFML community forums

General => Feature requests => Topic started by: cheeseboy on December 02, 2014, 11:51:25 pm

Title: Better way to get errors.
Post by: cheeseboy 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....
Title: Re: Better way to get errors.
Post by: eXpl0it3r on December 03, 2014, 12:14:58 am
You can redirect the buffer as shown in the documentation (http://sfml-dev.org/documentation/2.1/group__system.php#ga7fe7f475639e26334606b5142c29551f) (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.
Title: Re: Better way to get errors.
Post by: cheeseboy 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.
Title: Re: Better way to get errors.
Post by: eXpl0it3r 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...
Title: Re: Better way to get errors.
Post by: cheeseboy 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.
Title: Re: Better way to get errors.
Post by: eXpl0it3r 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.
Title: Re: Better way to get errors.
Post by: Hapax on December 03, 2014, 01:33:38 am
You can redirect the buffer as shown in the documentation (http://sfml-dev.org/documentation/2.1/group__system.php#ga7fe7f475639e26334606b5142c29551f)
...
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?
Title: Re: Better way to get errors.
Post by: Ixrec 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().