Using ThreadLocal to record more detailed error messages