Bug 42982 - improve UNO API error reporting
Summary: improve UNO API error reporting
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Libreoffice (show other bugs)
Version: Master old -3.6
Hardware: Other All
: medium minor
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: EasyHack DifficultyBeginner SkillCpp
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-16 03:04 UTC by Michael Stahl
Modified: 2014-01-20 09:00 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch to fix namecont.cxx (1012 bytes, patch)
2012-04-11 12:08 UTC, Abeer Sethi
Details | Splinter Review
This includes the suggested changes for namecont.cxx (1.02 KB, patch)
2012-04-12 05:39 UTC, Abeer Sethi
Details | Splinter Review
A patch for copytablewizard.cxx (2.11 KB, patch)
2012-04-12 05:40 UTC, Abeer Sethi
Details | Splinter Review

Description Michael Stahl 2011-11-16 03:04:28 UTC
There are many implementations of UNO APIs in LibreOffice,
and a lot of them have only very primitive error reporting.

In many cases the only form of error reporting used is
"throw RuntimeException;", which is completely unhelpful
to API users such as extension developers.

Such exceptions should be improved:

1. most importantly, an error message should be included in
   the exception so the API user may get some idea what
   is going wrong.
   for this, the newly introduced printf-style OSL_FORMAT
   macro may be useful.
   
2. in some cases a more specific exception than RuntimeException
   can be thrown.
   but beware that only the exceptions that are listed in the
   exception specification of the UNO API method may be thrown;
   subtypes of RuntimeException are always allowed, but there
   are surprising exceptions (IIRC IllegalArgumentException is
   one) that are not subtypes of RuntimeException.

the offending exceptions can easily be found with "git grep".
Comment 1 Abeer Sethi 2012-03-18 14:13:42 UTC
Can you tell me from my git-diff whether I'm on the right track?


http://pastebin.com/raw.php?i=XAR4s81e
Comment 2 Stephan Bergmann 2012-03-19 03:45:37 UTC
Re comment 1:

1  Lines are cut from the output in <http://pastebin.com/raw.php?i=XAR4s81e>.  (And better attach a patch to this issue than going via pastebin, anyway.)

2  For simple string messages like

  throw RuntimeException(OSL_FORMAT("XListener is not equal to 1"));

there is no need to go via OSL_FORMAT.  The standard idiom to create an rtl::OUString instance from an (ASCII) string literal for now is

  rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("XListener is not equal to 1"))

3  RuntimeException constructors either take no arguments or two arguments (Message, a string; and Context, a com::sun::star::uno::XInterface reference to the relevant UNO object or a null reference).

So, in basic/source/uno/namecont.cxx you would need a second argument

  static_cast< cppu::OWeakObject * >(this)

(where the cast is necessary as this derives from XInterface multiple times), and in the later files you would need to move your new, third argument to be the first one instead, replacing the empty "rtl::OUString()"
Comment 3 Abeer Sethi 2012-04-11 12:08:43 UTC
Created attachment 59811 [details] [review]
Patch to fix namecont.cxx
Comment 4 Stephan Bergmann 2012-04-12 00:45:56 UTC
(In reply to comment #3)
> Created attachment 59811 [details] [review] [review]
> Patch to fix namecont.cxx

See <http://lists.freedesktop.org/archives/libreoffice/2012-April/029894.html> for a comment about that patch.  (In general, it is better to present a patch for review in one place only, either in a bug or on the mailing list.)
Comment 5 Abeer Sethi 2012-04-12 05:39:44 UTC
Created attachment 59853 [details] [review]
This includes the suggested changes for namecont.cxx
Comment 6 Abeer Sethi 2012-04-12 05:40:45 UTC
Created attachment 59855 [details] [review]
A patch for copytablewizard.cxx
Comment 7 Stephan Bergmann 2012-04-23 12:13:21 UTC
(In reply to comment #5)
> Created attachment 59853 [details] [review] [review]
> This includes the suggested changes for namecont.cxx

pushed as <http://cgit.freedesktop.org/libreoffice/core/commit/?id=c9afb3f5a7f713d34f70b680c5d4ab3db4044d1c>
Comment 8 Stephan Bergmann 2012-04-23 12:14:43 UTC
(In reply to comment #6)
> Created attachment 59855 [details] [review] [review]
> A patch for copytablewizard.cxx

pushed as <http://cgit.freedesktop.org/libreoffice/core/commit/?id=67d022ac0ce5e67565e0589f4cd9eb05a8fd5a3c>
Comment 9 Florian Reisinger 2012-05-18 09:33:34 UTC
Deleted "Easyhack" from summary.
Comment 10 Michael Stahl 2012-06-29 14:10:36 UTC
Comment on attachment 59855 [details] [review]
A patch for copytablewizard.cxx

i'll mark this as "obsolete" since it was integrated,
so that it doesn't show up in bugzilla searches
Comment 11 Björn Michaelsen 2013-10-04 18:48:12 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 12 Cédric Bosdonnat 2014-01-20 09:00:36 UTC
Restricted my LibreOffice hacking area


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.