Allow to register an onerror callback