How to check for context loss

How to trap OpenGL context loss? In D3D there is a special function for that returning a value which indicates that.
An example is if i let Windows hibernate for a while, texture content gets lost. There is no problem to recreate it i just don’t know how to track it down.
I know there is some Windows message sent in that case, i need raw OpenGL though.

Looks like a driver bug, this should be handled transparently in OpenGL.
Drivers keep textures on their side ‘just in case’ something like that happens.