private void XCCUpload(FileInfo file) { Logger.Info("Entering XCCUpload"); ContentCreateOptions options = null; Session session = null; try { Uri uri = new Uri(ConfigurationManager.AppSettings["XCC_Connection"]); ContentSource cs = ContentSourceFactory.NewContentSource(uri); session = cs.NewSession(); Logger.Debug("Logging results for ContentSource"); this.LoadFile(session, file, options); } catch (Exception ex) { CMSException excption = new CMSException(ex.Message, ex); Logger.Error("Error on XCCUpload" + ex.Message); throw excption; } finally { session.Close(); } }
/// <summary> /// Fires on any exception in any controller /// </summary> /// <param name="context">http action context</param> public override void OnException(HttpActionExecutedContext context) { HttpError httpError = null; try { CMSException cmsException = context.Exception as CMSException; if (cmsException != null) { Logger.Error(cmsException.Message, cmsException); httpError = new HttpError(cmsException.ErrorMessage) { { "ErrorType", cmsException.ExceptionType } }; } else { Exception ex = context.Exception as Exception; //// Log the exception Logger.Error(ex.Message, ex); httpError = new HttpError(ex.Message) { { "ErrorType", CMSExceptionTypes.ServiceException } }; } } catch (Exception ex) { //// log the exception Logger.Error(ex.Message, ex); httpError = new HttpError(ex.Message) { { "ErrorType", CMSExceptionTypes.ServiceException } }; } throw new HttpResponseException(context.Request.CreateErrorResponse(HttpStatusCode.BadRequest, httpError)); }