Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Error

Contains information about errors that occur during Package Manager operations, including the error message and error code.
Read time 1 minuteLast updated 6 days ago

Definition

public class Error

Remarks

Common error codes include:
  • NotFound: The requested package was not found.
  • InvalidParameter: An invalid parameter was provided.
  • Conflict: A conflict occurred during the operation.
  • Unknown: An unspecified error occurred.
using System;using UnityEngine;using UnityEditor.PackageManager;using UnityEditor.PackageManager.Requests;[ExecuteInEditMode]public class PackageManagerErrorExample : MonoBehaviour{ AddRequest m_AddRequest; const string k_InvalidPackageName = "this is not a proper package name"; void Start() { Debug.Log("Create error condition during Package Manager request..."); m_AddRequest = Client.Add(k_InvalidPackageName); } void Update() { if (m_AddRequest != null && m_AddRequest.IsCompleted) { if (m_AddRequest.Status == StatusCode.Failure) { HandleError(m_AddRequest.Error); } else { Debug.Log($"Successfully installed {k_InvalidPackageName}"); } m_AddRequest = null; } } void HandleError(Error error) { switch (error.errorCode) { case ErrorCode.NotFound: Debug.LogError($"Package not found: {error.message}"); break; case ErrorCode.InvalidParameter: Debug.LogError($"Invalid parameter: {error.message}"); break; case ErrorCode.Conflict: Debug.LogError($"Package conflict: {error.message}"); break; default: Debug.LogError($"Package operation failed: {error.message}"); break; } }}
Related information

Properties

Property

Description

errorCodeNumerical error code.
messageError message or description.