Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

WWW.error

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public var error: string;
public string error;
public error as string

Description

Returns an error message if there was an error during the download (Read Only).

If there was no error, error will return null or an empty string (this is because some platforms don't allow nulls for string values). We recommend that you use String.IsNullOrEmpty to check for the presence of an error so that both cases are covered.

If the object has not finished downloading the data, it will block until the download has finished. Use isDone or yield to see if the data is available.

	// Get a texture with an invalid url
	var url = "invalid_url";
	function Start () {
	     // Start a download of the given URL
	    var www : WWW = new WWW (url);

// Wait for download to complete yield www;

// Print the error to the console if (!String.IsNullOrEmpty(www.error)) Debug.Log(www.error);

// assign texture renderer.material.mainTexture = www.texture; }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public string url = "invalid_url";
    IEnumerator Start() {
        WWW www = new WWW(url);
        yield return www;
        if (!String.IsNullOrEmpty(www.error))
            Debug.Log(www.error);
        
        renderer.material.mainTexture = www.texture;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public url as string = 'invalid_url'

	def Start() as IEnumerator:
		www as WWW = WWW(url)
		yield www
		if not String.IsNullOrEmpty(www.error):
			Debug.Log(www.error)
		renderer.material.mainTexture = www.texture