Exceptions in upload complete do not produce an error

Aug 13, 2012 at 11:32 AM
Edited Aug 13, 2012 at 2:55 PM

Hello,

I am doing some post-upload manipulations to the files and I found that I did not have a way of handling any errors or exceptions. Just changing the upload response message was not enough because the file was still listed as finished in the user's dialog. I made the following 4 changes and wanted to share them in case they were useful to others.

-- Added new response to HSS.Interlink.Web Responses

        /// <summary>
        /// Exception On Complete
        /// </summary>
        public static string ExceptionOnComplete = "Exception On Complete";


-- Added try catch to HSS.Interlink.Web BaseUploadHandler IUploadHandler.Upload,
    in case "GET":
       and case FileQueryCommand.UploadComplete:
            replace: result = this.UploadComplete();

                                try
                                {
                                    result = this.UploadComplete();
                                }
                                catch(Exception ex)
                                {

                                    OnError(ex);
                                    result = Response.ExceptionOnComplete + ex.Message;
                                }


-- Added new reponse to HSS.Interlink UploadFileWriter Responses

            /// <summary>
            /// Exception On Complete
            /// </summary>
            public const string ExceptionOnComplete = "Exception On Complete";


-- Added if statement to HSS.Interlink UploadFileWriter ReadCompleteResponse
 below webResponse.Close();

                    if(response.StartsWith(Responses.ExceptionOnComplete))
                    {
                        var message = response.Substring(Responses.ExceptionOnComplete.Length);
                        this.SetFileError(new WebException(message));
                        return;
                    }

Coordinator
Aug 17, 2012 at 4:13 PM

Excellent, thanks for sharing. Also, from the looks of it, you're using v2.0?