Print only part of a stack trace

Stanislav Blinov stanislav.blinov at gmail.com
Wed Jul 1 18:44:10 UTC 2020


On Wednesday, 1 July 2020 at 18:30:15 UTC, Dennis wrote:

> I have a function that checks a global error constant of a C 
> library (OpenGL) like this:
> ```
> void assertNoOpenGLErrors() {
>     if (glGetError() != GL_NO_ERROR) {
>         assert(0); // stack trace points to here instead of 
> caller
>     }
> }
> ```
>
> And I would like to rewrite it to this:
> ```
> void assertNoOpenGLErrors() {
>     if (glGetError() != GL_NO_ERROR) {
>         print(getStackTrace().filterTrace());
>         exit();
>     }
> }
> ```

void assertNoOpenGLErrors(string file = __FILE__, int line = 
__LINE__, string func = __PRETTY_FUNCTION__)
{
     if (glGetError() != GL_NO_ERROR) {
         print(file, ":", line, ":", func, ": blah");
         exit();
     }
}

:)


More information about the Digitalmars-d-learn mailing list