Exemplo n.º 1
0
        internal static void ThrowIfError(this RecorderErrorCode errorCode, string errorMessage)
        {
            if (errorCode == RecorderErrorCode.None)
            {
                return;
            }

            switch (errorCode)
            {
            case RecorderErrorCode.InvalidParameter:
                throw new ArgumentException(errorMessage);

            case RecorderErrorCode.OutOfMemory:
                throw new OutOfMemoryException($"{errorMessage}.");

            case RecorderErrorCode.DeviceError:
            case RecorderErrorCode.Esd:
                throw new RecorderDeviceException($"{errorMessage}; {errorCode.ToString()}.");

            case RecorderErrorCode.SecurityRestricted:
                throw new UnauthorizedAccessException($"The feature is currently disabled by the device policy; {errorCode.ToString()}.");

            case RecorderErrorCode.PermissionDenied:
                throw new UnauthorizedAccessException($"{errorMessage}; {errorCode.ToString()}.");

            case RecorderErrorCode.NotSupported:
                throw new NotSupportedException($"{errorMessage}.");

            case RecorderErrorCode.InvalidState:
            case RecorderErrorCode.InvalidOperation:
            case RecorderErrorCode.ResourceConflict:
            case RecorderErrorCode.ServiceDisconnected:
                throw new InvalidOperationException($"{errorMessage}; {errorCode.ToString()}.");

            case RecorderErrorCode.OutOfStorage:
                throw new IOException($"{errorMessage}; Not enough disk space or specified path is not available to .");

            default:
                throw new Exception($"Unknown error : {errorCode.ToString()}.");
            }
        }
Exemplo n.º 2
0
 internal static RecorderErrorCode Ignore(this RecorderErrorCode errorCode, RecorderErrorCode ignore)
 {
     return((ignore == errorCode) ? RecorderErrorCode.None : errorCode);
 }