Kaydet (Commit) 2d2337eb authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Improve some debug output

Change-Id: I1008822ba8592ea43f87805bf00adbfdaf4f02fc
üst 5be1f523
......@@ -574,10 +574,22 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, sal_Bool
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::ucb::ContentCreationException&)
{ return sal_False; } // TODO error handling
catch(const css::uno::Exception&)
{ return sal_False; } // TODO error handling
catch(const css::ucb::ContentCreationException& e)
{
SAL_WARN(
"comphelper",
"caught ContentCreationException \"" << e.Message
<< "\" while opening <" << sURL << ">");
return sal_False; // TODO error handling
}
catch(const css::uno::Exception& e)
{
SAL_WARN(
"comphelper",
"caught Exception \"" << e.Message << "\" while opening <"
<< sURL << ">");
return sal_False; // TODO error handling
}
// try to open the file in read/write mode
// (if its allowed to do so).
......@@ -606,7 +618,7 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, sal_Bool
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
catch(const css::uno::Exception& e)
{
// ignore exception, if reason was problem reasoned on
// open it in WRITEABLE mode! Then we try it READONLY
......@@ -614,7 +626,13 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, sal_Bool
// All other errors must be handled as real error an
// break this method.
if (!pInteraction->wasWriteError() || bModeRequestedExplicitly)
{
SAL_WARN(
"comphelper",
"caught Exception \"" << e.Message
<< "\" while opening <" << sURL << ">");
return sal_False;
}
xStream.clear();
xInputStream.clear();
}
......@@ -667,8 +685,14 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, sal_Bool
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
{ return sal_False; }
catch(const css::uno::Exception& e)
{
SAL_WARN(
"comphelper",
"caught Exception \"" << e.Message << "\" while opening <"
<< sURL << ">");
return sal_False;
}
}
// add streams to the descriptor
......
......@@ -445,8 +445,14 @@ OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css::
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
{ sType = OUString(); }
catch(const css::uno::Exception& e)
{
SAL_WARN(
"filter.config",
"caught Exception \"" << e.Message
<< "\" while querying type of <" << sURL << ">");
sType = OUString();
}
//*******************************************
// adapt media descriptor, so it contains the right values
......@@ -1138,7 +1144,9 @@ void TypeDetection::impl_openStream(::comphelper::MediaDescriptor& rDescriptor)
bSuccess = rDescriptor.addInputStream();
if ( !bSuccess )
throw css::uno::Exception(_FILTER_CONFIG_FROM_ASCII_("Could not open stream."), static_cast< css::document::XTypeDetection* >(this));
throw css::uno::Exception(
"Could not open stream for <" + sURL + ">",
static_cast<OWeakObject *>(this));
if ( !bRequestedReadOnly )
{
......
......@@ -29,7 +29,6 @@ namespace framework{
//_________________________________________________________________________________________________________________
#define SERVICENAME_FILTERFACTORY DECLARE_ASCII("com.sun.star.document.FilterFactory" )
#define SERVICENAME_TYPEDETECTION DECLARE_ASCII("com.sun.star.document.TypeDetection" )
#define SERVICENAME_CFGUPDATEACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationUpdateAccess") // provides read/write access to the configuration
#define SERVICENAME_CFGREADACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationAccess" ) // provides readonly access to the configuration
#define SERVICENAME_CONTENTHANDLER DECLARE_ASCII("com.sun.star.frame.ContentHandler" )
......
......@@ -122,8 +122,20 @@ css::uno::Any LoadDispatcher::impl_dispatch( const css::util::URL& rURL,
// TODO thinking about asynchronous operations and listener support
}
catch(const LoadEnvException&)
{ xComponent.clear(); }
catch(const LoadEnvException& e)
{
SAL_WARN(
"fwk.dispatch",
"caught LoadEnvException " << +e.m_nID << " \"" << e.m_sMessage
<< "\""
<< (e.m_exOriginal.has<css::uno::Exception>()
? (", " + e.m_exOriginal.getValueTypeName() + " \""
+ e.m_exOriginal.get<css::uno::Exception>().Message
+ "\"")
: OUString())
<< " while dispatching <" << rURL.Complete << ">");
xComponent.clear();
}
if (xListener.is())
{
......
......@@ -32,15 +32,10 @@ namespace framework{
@descr Of course outside code must wrapp it, to transport
the occurred information to its caller.
@author as96863
*/
class LoadEnvException
{
public:
/** @short Can be used as an ID for an instance of a LoadEnvException.
@descr To prevent errors on adding/removing/changing such IDs here,
an enum field is used. Its int values are self organized ...
......@@ -93,76 +88,17 @@ class LoadEnvException
ID_GENERAL_ERROR
};
//___________________________________________
// member
public:
/** @short contains a suitable message, which describes the reason for this
exception. */
OString m_sMessage;
/** @short An ID, which make this exception unique among others. */
sal_Int32 m_nID;
/** @short Contains the original exception, if any occurred. */
OUString m_sMessage;
css::uno::Any m_exOriginal;
/** TODO
Experimental use! Maybe it can be useful to know if an exception was already
catched and handled by an interaction and might be rethrown! */
sal_Bool m_bHandled;
//___________________________________________
// interface
public:
/** @short initialize a new instance with an ID.
@descr Some other items of this exception
(e.g. a suitable message) will be generated
automaticly.
LoadEnvException(
sal_Int32 id, OUString const & message = OUString(),
css::uno::Any const & original = css::uno::Any()):
m_nID(id), m_sMessage(message), m_exOriginal(original)
{}
@param nID
One of the defined const IDs of this class.
*/
LoadEnvException(sal_Int32 nID)
{
m_nID = nID;
}
//_______________________________________
/** @short initialize a new instance with an ID
an wrap a detected exception into this one.
@descr Some other items of this exception
(e.g. a suitable message) will be generated
automaticly.
@param nID
One of the defined const IDs of this class.
@param exUno
the original catched uno exception.
*/
LoadEnvException( sal_Int32 nID ,
const css::uno::Any& exUno)
{
m_nID = nID ;
m_exOriginal = exUno;
}
//_______________________________________
/** @short destruct an instance of this exception.
*/
~LoadEnvException()
{
m_sMessage = OString();
m_nID = 0;
m_bHandled = false;
m_exOriginal.clear();
}
~LoadEnvException() {}
};
} // namespace framework
......
......@@ -182,23 +182,23 @@ css::uno::Reference< css::lang::XComponent > LoadEnv::loadComponentFromURL(const
"Optional list of arguments seem to be corrupted.", xLoader, 4);
case LoadEnvException::ID_UNSUPPORTED_CONTENT:
{
OUStringBuffer aMsg;
aMsg.appendAscii("Unsupported URL <").append(sURL).append('>');
if (!ex.m_sMessage.isEmpty())
{
aMsg.appendAscii(": \"").
append(OStringToOUString(
ex.m_sMessage, RTL_TEXTENCODING_UTF8)).
appendAscii("\"");
}
throw css::lang::IllegalArgumentException(aMsg.makeStringAndClear(),
throw css::lang::IllegalArgumentException(
("Unsupported URL <" + sURL + ">" + ": \"" + ex.m_sMessage
+ "\""),
xLoader, 1);
}
default:
SAL_WARN(
"fwk.loadenv",
"caught LoadEnvException " << +ex.m_nID << " \""
<< ex.m_sMessage << "\""
<< (ex.m_exOriginal.has<css::uno::Exception>()
? (", " + ex.m_exOriginal.getValueTypeName() + " \""
+ (ex.m_exOriginal.get<css::uno::Exception>().
Message)
+ "\"")
: OUString())
<< " while loading <" << sURL << ">");
xComponent.clear();
break;
}
......@@ -261,7 +261,7 @@ void LoadEnv::initializeLoading(const OUString&
{
m_eContentType = LoadEnv::classifyContent(sURL, lMediaDescriptor);
if (m_eContentType == E_UNSUPPORTED_CONTENT)
throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT);
throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT, "from LoadEnv::initializeLoading");
}
// make URL part of the MediaDescriptor
......@@ -369,7 +369,7 @@ void LoadEnv::startLoading()
// content can not be loaded or handled
// check "classifyContent()" failed before ...
if (m_eContentType == E_UNSUPPORTED_CONTENT)
throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT);
throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT, "from LoadEnv::startLoading");
// <- SAFE
aReadLock.unlock();
......@@ -640,8 +640,9 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString&
// following operations can work on an internal type name only :-(
css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
css::uno::Reference< css::document::XTypeDetection > xDetect(
xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_TYPEDETECTION, xContext),
css::uno::UNO_QUERY);
xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.document.TypeDetection", xContext),
css::uno::UNO_QUERY_THROW);
OUString sType = xDetect->queryTypeByURL(sURL);
......@@ -807,13 +808,16 @@ void LoadEnv::impl_detectTypeAndFilter()
return;
}
css::uno::Reference< css::document::XTypeDetection > xDetect( xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_TYPEDETECTION, xContext), css::uno::UNO_QUERY);
if (xDetect.is())
sType = xDetect->queryTypeByDescriptor(lDescriptor, sal_True); /*TODO should deep detection be able for enable/disable it from outside? */
css::uno::Reference< css::document::XTypeDetection > xDetect(
xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.document.TypeDetection", xContext),
css::uno::UNO_QUERY_THROW);
sType = xDetect->queryTypeByDescriptor(lDescriptor, sal_True); /*TODO should deep detection be able for enable/disable it from outside? */
// no valid content -> loading not possible
if (sType.isEmpty())
throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT);
throw LoadEnvException(
LoadEnvException::ID_UNSUPPORTED_CONTENT, "type detection failed");
// SAFE ->
WriteGuard aWriteLock(m_aLock);
......@@ -1681,7 +1685,7 @@ void LoadEnv::impl_reactForLoadingState()
if (bThrow)
{
if ( aRequest.isExtractableTo( ::cppu::UnoType< css::uno::Exception >::get() ) )
throw LoadEnvException( LoadEnvException::ID_GENERAL_ERROR, aRequest );
throw LoadEnvException( LoadEnvException::ID_GENERAL_ERROR, "", aRequest );
}
// <- SAFE ----------------------------------
......
......@@ -1151,7 +1151,7 @@ void AutoRecovery::implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocume
xModuleProps->getByName(OUString(CFG_ENTRY_REALDEFAULTFILTER)) >>= rInfo.DefaultFilter;
css::uno::Reference< css::container::XNameAccess > xFilterCFG(xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_FILTERFACTORY, xContext), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::container::XNameAccess > xTypeCFG (xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_TYPEDETECTION, xContext), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::container::XNameAccess > xTypeCFG (xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", xContext), css::uno::UNO_QUERY_THROW);
::comphelper::SequenceAsHashMap lFilterProps (xFilterCFG->getByName(rInfo.DefaultFilter));
OUString sTypeRegistration = lFilterProps.getUnpackedValueOrDefault(OUString(FILTER_PROP_TYPE), OUString());
......
......@@ -152,10 +152,11 @@ certain functionality.
@section framework
@li @c fwk - framework (abbreviation)
@li @c fwk.accelerators
@li @c fwk.desktop
@li @c fwk.dispatch
@li @c fwk.loadenv
@li @c fwk.session
@li @c fwk.accelerators
@li @c fwk.uielement
@section i18nlangtag
......@@ -277,6 +278,7 @@ certain functionality.
@li @c ucb
@li @c ucb.ucp
@li @c ucb.ucp.gio
@li @c ucb.ucp.gvfs
@li @c ucb.ucp.webdav
@section unotools
......
......@@ -1122,7 +1122,14 @@ Content::getInfo( const uno::Reference< ucb::XCommandEnvironment >& xEnv )
result = gnome_vfs_get_file_info
( aURI.getStr(), &m_info, GNOME_VFS_FILE_INFO_DEFAULT );
if (result != GNOME_VFS_OK)
{
SAL_WARN(
"ucb.ucp.gvfs",
"gnome_vfs_get_file_info for <" << aURI << "> failed with \""
<< gnome_vfs_result_to_string(result) << "\" (" << +result
<< ")");
gnome_vfs_file_info_clear( &m_info );
}
} else
result = GNOME_VFS_OK;
#if OSL_DEBUG_LEVEL > 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment