示例#1
0
        public PedamorfResponse GetResponse(Func <PdfConverter, byte[]> conversion)
        {
            PedamorfResponse response = new PedamorfResponse();

            try
            {
                response.ResultPdf = conversion(m_converter);
            }
            catch (MissingSourceException missingSourceEx)
            {
                m_logger.ErrorException("Source is missing or undefinied.", missingSourceEx);

                response.Error        = true;
                response.ErrorMessage = missingSourceEx.Message;
                response.ErrorCode    = ErrorCodeEnum.UNDEFINED_SOURCE;
            }
            catch (ConversionTimeoutException timeoutEx)
            {
                m_logger.ErrorException("Conversion engine timeout.", timeoutEx);

                response.Error        = true;
                response.ErrorMessage = timeoutEx.Message;
                response.ErrorCode    = ErrorCodeEnum.TIMEOUT;
            }
            catch (UrlFetchException urlFetchEx)
            {
                m_logger.ErrorException("Url fetch failed.", urlFetchEx);

                response.Error        = true;
                response.ErrorMessage = urlFetchEx.Message;
                response.ErrorCode    = ErrorCodeEnum.COULD_NOT_FETCH_URL;
            }
            catch (ConversionEngineException conversionEx)
            {
                m_logger.ErrorException("Conversion engine failed.", conversionEx);

                response.Error        = true;
                response.ErrorMessage = "Conversion engine failed.";
                response.ErrorCode    = ErrorCodeEnum.ENGINE_ERROR;
            }
            catch (UnsupportedSourceException unsupportedException)
            {
                m_logger.ErrorException("Unsupported type.", unsupportedException);

                response.Error        = true;
                response.ErrorMessage = unsupportedException.Message;
                response.ErrorCode    = ErrorCodeEnum.UNSUPPORTED_SOURCE;
            }
            catch (Exception ex)
            {
                m_logger.ErrorException("Conversion exception occured.", ex);

                response.Error        = true;
                response.ErrorMessage = ex.Message;
                response.ErrorCode    = ErrorCodeEnum.OTHER;
            }

            return(response);
        }
示例#2
0
        public PedamorfResponse GetResponse(Func<PdfConverter, byte[]> conversion)
        {
            PedamorfResponse response = new PedamorfResponse();

            try
            {
                response.ResultPdf = conversion(m_converter);
            }
            catch (MissingSourceException missingSourceEx)
            {
                m_logger.ErrorException("Source is missing or undefinied.", missingSourceEx);

                response.Error = true;
                response.ErrorMessage = missingSourceEx.Message;
                response.ErrorCode = ErrorCodeEnum.UNDEFINED_SOURCE;
            }
            catch (ConversionTimeoutException timeoutEx)
            {
                m_logger.ErrorException("Conversion engine timeout.", timeoutEx);

                response.Error = true;
                response.ErrorMessage = timeoutEx.Message;
                response.ErrorCode = ErrorCodeEnum.TIMEOUT;
            }
            catch (UrlFetchException urlFetchEx)
            {
                m_logger.ErrorException("Url fetch failed.", urlFetchEx);

                response.Error = true;
                response.ErrorMessage = urlFetchEx.Message;
                response.ErrorCode = ErrorCodeEnum.COULD_NOT_FETCH_URL;
            }
            catch (ConversionEngineException conversionEx)
            {
                m_logger.ErrorException("Conversion engine failed.", conversionEx);

                response.Error = true;
                response.ErrorMessage = "Conversion engine failed.";
                response.ErrorCode = ErrorCodeEnum.ENGINE_ERROR;
            }
            catch (UnsupportedSourceException unsupportedException)
            {
                m_logger.ErrorException("Unsupported type.", unsupportedException);

                response.Error = true;
                response.ErrorMessage = unsupportedException.Message;
                response.ErrorCode = ErrorCodeEnum.UNSUPPORTED_SOURCE;
            }
            catch (Exception ex)
            {
                m_logger.ErrorException("Conversion exception occured.", ex);

                response.Error = true;
                response.ErrorMessage = ex.Message;
                response.ErrorCode = ErrorCodeEnum.OTHER;
            }

            return response;
        }