Sometimes, we may encounter corrupted files, or files with unknown extensions.
Will be good if GroupDocs.Conversion can fail gracefully when it encounters such situations.
Attached is a simple text file with filename “unknown.ext”:
sample.zip (211 Bytes)
Using the following piece of code:
GroupDocs.Conversion.FluentConverter.Load("unknown.ext").ConvertTo("unknown.pdf").Convert();
It will throw exception:
Unhandled Exception: GroupDocs.Conversion.Exceptions.GroupDocsConversionException: Exception of type 'System.OutOfMemoryException' was thrown. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at #=zrQ6_h4UFvAKeklZwiAJuWbC8d9ruwsNhkqyEgRo=.#=zDwEkrHY=()
at #=zrQ6_h4UFvAKeklZwiAJuWbC8d9ruwsNhkqyEgRo=.#=zBUUz38NRe6pH(UInt32 #=zTHPuERo=, UInt32 #=zX6R5N1k=)
at #=z2SjnS366aNpomxa3dg0xQxBblm5vUvUHuQ8$gHw=.#=zPn1zWWo=(Stream #=zprx9fQwmEYm0, Stream #=zr3sW9y78JnlT, Int64 #=z6LKql5U=, Int64 #=zrKH$FEo=, #=zcEtrG94Em$R$ilhRmzzQZup5qZlt_$cE$A== #=zICd4QTs=, Boolean #=zN1MUkMyX_nj1)
at Aspose.Zip.LZMA.LzmaArchive.Extract(Stream destination)
at ..MoveNext()
at ? ..MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at .(Exception )
at .(Object )
at .(MethodBase , Boolean)
at .( )
at . ( , )
at . ()
at .(Boolean )
--- End of stack trace from previous location where exception was thrown ---
at .(Exception )
at .(Object )
at . ()
at .?( , )
at . ()
at .(Boolean )
--- End of stack trace from previous location where exception was thrown ---
at .(Exception )
at .(Object )
at . ()
at .(Object , UInt32)
at .(Boolean )
at .(Boolean )
at . ()
at .(Object[] , Type[], Type[] , Object[] )
at .(Stream , String, Object[] , Type[] , Type[] , Object[] )
at (Stream , String, Object[] )
at ? .MoveNext()
at (CancellationToken )
at .()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at ..(Exception )
at System.AggregateException.Handle(Func`2 predicate)
at .(CancellationToken )
at .Convert(CancellationToken )