From 4d948b90bd63c48f904b5bd5189d8638674de2d6 Mon Sep 17 00:00:00 2001 From: "mvl%exedo.nl" Date: Fri, 30 Sep 2005 17:09:38 +0000 Subject: [PATCH] propagate libical errors through the ics service. part of bug 306508, r=dmose --- calendar/base/public/calIErrors.idl | 21 +++++++++++++++++++++ calendar/base/src/calICSService.cpp | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/calendar/base/public/calIErrors.idl b/calendar/base/public/calIErrors.idl index 56d65940564..c42e42252ac 100644 --- a/calendar/base/public/calIErrors.idl +++ b/calendar/base/public/calIErrors.idl @@ -61,5 +61,26 @@ interface calIErrors : nsISupports * An invalid or nonexistent timezone was encountered. */ const unsigned long INVALID_TIMEZONE = ERROR_BASE + 1; + + + /* ICS specific errors */ + const unsigned long ICS_ERROR_BASE = ERROR_BASE + 0x100; + + /** + * ICS errors, copied from icalerror.h. + * The numbers (minus ICS_ERROR_BASE) should match with the enum + * values from icalerror.h + */ + const unsigned long ICS_NO_ERROR = ICS_ERROR_BASE + 0; + const unsigned long ICS_BADARG = ICS_ERROR_BASE + 1; + const unsigned long ICS_NEWFAILED = ICS_ERROR_BASE + 2; + const unsigned long ICS_ALLOCATION = ICS_ERROR_BASE + 3; + const unsigned long ICS_MALFORMEDDATA = ICS_ERROR_BASE + 4; + const unsigned long ICS_PARSE = ICS_ERROR_BASE + 5; + const unsigned long ICS_INTERNAL = ICS_ERROR_BASE + 6; + const unsigned long ICS_FILE = ICS_ERROR_BASE + 7; + const unsigned long ICS_USAGE = ICS_ERROR_BASE + 8; + const unsigned long ICS_UNIMPLEMENTED = ICS_ERROR_BASE + 9; + const unsigned long ICS_UNKNOWN = ICS_ERROR_BASE + 10; }; diff --git a/calendar/base/src/calICSService.cpp b/calendar/base/src/calICSService.cpp index 357ef1000b8..cd49bfcae39 100644 --- a/calendar/base/src/calICSService.cpp +++ b/calendar/base/src/calICSService.cpp @@ -49,6 +49,7 @@ #include "calIEvent.h" #include "calBaseCID.h" +#include "calIErrors.h" static NS_DEFINE_CID(kCalICSService, CAL_ICSSERVICE_CID); @@ -964,7 +965,9 @@ calICSService::ParseICS(const nsACString& serialized, PromiseFlatCString(serialized).get(), icalerrno, icalerror_strerror(icalerrno)); #endif - return NS_ERROR_FAILURE; + // The return values is calIError match with ical errors, + // so no need for a conversion table or anything. + return calIErrors::ICS_ERROR_BASE + icalerrno; } calIcalComponent *comp = new calIcalComponent(ical, nsnull); if (!comp) {