Make simple error function create a cache and use.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>