コード例 #1
0
        public void LzaResultConstructor_Works(LzmaResult result, string expectedMessage)
        {
            var ex = new LzmaException(result);

            Assert.Equal(result, (LzmaResult)ex.HResult);
            Assert.Equal(expectedMessage, ex.Message);
        }
コード例 #2
0
 /// <summary>
 /// Throws a <see cref="LzmaException"/> if <see cref="LzmaResult"/> is not <see cref="LzmaResult.OK"/>.
 /// </summary>
 /// <param name="result">
 /// The result value to check.
 /// </param>
 public static void ThrowOnError(LzmaResult result)
 {
     if (result != LzmaResult.OK)
     {
         throw new LzmaException(result);
     }
 }
コード例 #3
0
        private static Exception GetError(LzmaResult ret)
        {
            switch (ret)
            {
            case LzmaResult.MemError: return(new OutOfMemoryException("Memory allocation failed"));

            case LzmaResult.OptionsError: return(new ArgumentException("Specified preset is not supported"));

            case LzmaResult.UnsupportedCheck: return(new Exception("Specified integrity check is not supported"));

            case LzmaResult.DataError: return(new InvalidDataException("File size limits exceeded"));

            default: return(new Exception("Unknown error, possibly a bug: " + ret));
            }
        }
コード例 #4
0
 private Exception ThrowError(LzmaResult ret)
 {
     NativeMethods.lzma_end(ref this.lzmaStream);
     return(GetError(ret));
 }
コード例 #5
0
 private static string GetDescription(LzmaResult result) =>
 result switch
 {
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LzmaException"/> class, based on an <see cref="LzmaResult"/>
 /// error code.
 /// </summary>
 /// <param name="result">
 /// A message which describes the error.
 /// </param>
 public LzmaException(LzmaResult result)
     : base(GetDescription(result))
 {
     this.HResult = (int)result;
 }