The problem with Kenny Saelen's approach is that many CLRInterop errors are of such a level that they break through the Dynamics AX X++ catch clause regardless of it being specified to catch an Exception::CLRError. I've encountered this before when using the System.IO methods such as file moves/deletes.
One way to better see your error (since you cant catch it properly in X++) is to rewrite your job in .NET code and use a .NET catch block which is perfectly capable of catching that error. Build the objects in a C# console application and recreate the same behavior encapsulated in a .NET try/catch.
Something like this:
static void Main(string[] args)
{
System.String decodedString;
System.Byte[] buffer;
System.IO.Compression.GZipStream gzip;
System.IO.StreamWriter writer;
System.IO.MemoryStream output;
string compressedString = "sample";
buffer = System.Convert.FromBase64String(compressedString);
output = new System.IO.MemoryStream(buffer);
gzip = new System.IO.Compression.GZipStream(output, System.IO.Compression.CompressionMode.Decompress);
try
{
writer = new System.IO.StreamWriter(gzip);
writer.Write(decodedString);
writer.Close();
Console.Write(decodedString);
Console.ReadKey();
}
catch (Exception ex)
{
Console.Write(ex.Message);
Console.ReadKey();
}
}
Let me know if that works for you Spankachu.
Cheers