// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System; using UltimateXR.Core.Unique; namespace UltimateXR.Exceptions { /// /// UltimateXR Component not found exception. This exception is normally thrown when a method that uses /// could not find the component. /// itself doesn't throw any exception. /// public sealed class UxrComponentNotFoundException : Exception { #region Public Types & Data /// /// Gets the component's unique ID that could not be found. /// public Guid UniqueId { get; } #endregion #region Constructors & Finalizer /// /// Constructor. /// /// The unique ID of the component that was going to be retrieved /// Exception message public UxrComponentNotFoundException(Guid uniqueId, string message = null) : base(FormatMessage(uniqueId, message)) { UniqueId = uniqueId; } #endregion #region Private Methods /// /// Gets a formatted exception message. /// /// The unique ID of the component that was going to be retrieved /// Original message /// Exception message private static string FormatMessage(Guid uniqueId, string message) { string prefix = string.IsNullOrEmpty(message) ? $"{message}: " : string.Empty; return $"{prefix}Could not find the given component using {nameof(UxrUniqueIdImplementer)}.{nameof(UxrUniqueIdImplementer.TryGetComponentById)}(). Id is {(uniqueId != null ? uniqueId == default ? "empty" : uniqueId : "null")}."; } #endregion } }