Beispiel #1
0
 internal static MediaContentError Ignore(this MediaContentError err, params MediaContentError[] ignores)
 {
     if (ignores.Contains(err))
     {
         return(MediaContentError.None);
     }
     return(err);
 }
Beispiel #2
0
        internal static void ThrowIfError(this MediaContentError err, string msg)
        {
            if (err == MediaContentError.None)
            {
                return;
            }

            throw err.AsException(msg);
        }
Beispiel #3
0
        internal static Exception AsException(this MediaContentError err, string msg)
        {
            Debug.Assert(err != MediaContentError.None);

            switch (err)
            {
            case MediaContentError.InvalidParameter:
                return(new ArgumentException($"{msg}."));

            case MediaContentError.OutOfMemory:
                return(new OutOfMemoryException($"{msg}."));

            case MediaContentError.InvalidOperation:
                return(new InvalidOperationException($"{msg}."));

            case MediaContentError.FileNoSpaceOnDevice:
                return(new IOException($"{msg} : {err}."));

            case MediaContentError.PermissionDenied:
                return(new UnauthorizedAccessException($"{msg}."));

            case MediaContentError.DatabaseFailed:
                return(new MediaDatabaseException(MediaDatabaseError.OperationFailed));

            case MediaContentError.DatabaseBusy:
                return(new MediaDatabaseException(MediaDatabaseError.DatabaseBusy));

            case MediaContentError.NetworkFailed:
                return(new InvalidOperationException($"{msg} : {err}."));

            case MediaContentError.UnsupportedContent:
                return(new UnsupportedContentException());

            case MediaContentError.NotSupported:
                return(new NotSupportedException($"{msg}."));

            default:
                return(new InvalidOperationException($"Unknown Error : {err.ToString()}, {msg}."));
            }
        }