// Gets called for every error scenario encountered during an operation. // A common use case for this is having InvalidKeyExceptions fail silently when // a location is missing for a given key. void CustomExceptionHandler(AsyncOperationHandle handle, Exception exception) { if (exception.GetType() != typeof(InvalidKeyException)) { Addressables.LogException(handle, exception); } }
public void Update(double diff, int bytesPerSecond) { if (m_Context == null || m_ReadFileStream == null) { return; } int countToRead = (int)(bytesPerSecond * diff); try { while (countToRead > 0) { int count = countToRead > m_ReadByteBuffer.Length ? m_ReadByteBuffer.Length : countToRead; int read = m_ReadFileStream.Read(m_ReadByteBuffer, 0, count); m_Context.Response.OutputStream.Write(m_ReadByteBuffer, 0, read); m_TotalBytesRead += read; countToRead -= count; if (m_TotalBytesRead == m_ReadFileStream.Length) { Stop(); break; } } } catch (Exception e) { string url = m_Context.Request.Url.ToString(); Stop(); if (e.InnerException != null && e.InnerException is SocketException && e.InnerException.Message == "The socket has been shut down") { Addressables.LogWarning($"Connection lost: {url}. The socket has been shut down."); } else { Addressables.LogException(e); throw; } } }