Make error structure more generic