More specific exception for unsupported bundle decompression

This commit is contained in:
Jeremy Pritts 2023-09-04 23:58:15 -04:00
parent 7e444df657
commit d50ee0995e
2 changed files with 20 additions and 1 deletions

View File

@ -93,7 +93,8 @@ namespace AssetRipper.IO.Files.BundleFiles.FileStream
break;
default:
throw new NotSupportedException($"Bundle compression '{metaCompression}' isn't supported");
UnsupportedBundleDecompression.Throw(NameFixed, metaCompression);
break;
}
}

View File

@ -0,0 +1,18 @@
using AssetRipper.IO.Files.BundleFiles;
namespace AssetRipper.IO.Files.Exceptions;
public sealed class UnsupportedBundleDecompression : NotSupportedException
{
private UnsupportedBundleDecompression(string message) : base(message) { }
[DoesNotReturn]
public static void Throw(string fileName, CompressionType compression)
{
throw compression switch
{
CompressionType.Lzham => new UnsupportedBundleDecompression($"Lzham decompression is not currently supported. File: {fileName}"),
_ => new UnsupportedBundleDecompression($"Bundle compression '{compression}' is not supported. '{fileName}' is likely encrypted or using a custom compression algorithm."),
};
}
}