Exception handling in biztalk 2006 R2

Posted by IB on Stack Overflow See other posts from Stack Overflow or by IB
Published on 2010-03-16T09:45:10Z Indexed on 2010/03/16 9:46 UTC
Read the original article Hit count: 343

Filed under:
|
|

Hello

I have a Biztalk 2006 R2 project (used with ESB Guidance 1) I am calling from orchstration to a static method in c# code, this method uses a class to load a file data into xlang message body at part 0 When i pass filepath which doesnt exists the inside class catch the exception but dont throw it up (in the static method there is a catch block and in the orchstration there is the real handling of the exception)

The static method is :


public static XLANGMessage LoadFileIntoMessage(XLANGMessage message, string filePath,Encoding encoding)
        {
            try
            {
                IStreamFactory sf = new FileStreamFactory(filePath,encoding);

                message[0].LoadFrom(sf);
                return message;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

The Class which load the file stream is :


private class FileStreamFactory : IStreamFactory
        {
            string _fname;
            Encoding _encoding;

            public FileStreamFactory(string fname,Encoding encoding)
            {
                _fname = fname;
                _encoding = encoding;
            }

            public Stream CreateStream()
            {
                try
                {
                    StreamReader sr;
                    sr = new StreamReader
                    (
                        _fname,
                        _encoding
                    );

                    return sr.BaseStream;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }

I call the static method from the orchstration and expect to catch the exception in my orchstration after the class and the emthod gets it

© Stack Overflow or respective owner

Related posts about biztalk2006r2

Related posts about BizTalk