Implemented setLoading and setError.