Bug 325519: Better readable error dialog. r=jminta

This commit is contained in:
mvl%exedo.nl 2006-03-21 18:32:46 +00:00
Родитель d8f81df51d
Коммит a8adc18592
4 изменённых файлов: 37 добавлений и 15 удалений

Просмотреть файл

@ -67,6 +67,11 @@ interface calIErrors : nsISupports
*/
const unsigned long CAL_IS_READONLY = ERROR_BASE + 2;
/**
* Error while decoding an (ics) file from utf8
*/
const unsigned long CAL_UTF8_DECODING_FAILED = ERROR_BASE + 3;
/* ICS specific errors */
const unsigned long ICS_ERROR_BASE = ERROR_BASE + 0x100;

Просмотреть файл

@ -412,19 +412,31 @@ errorAnnouncer.prototype.announceError = function(aErrNo, aMessage) {
// When possible, change the error number into its name, to
// make it slightly more readable.
var errCode = "0x"+aErrNo.toString(16);
const calIError = Components.interfaces.calIErrors;
const calIErrors = Components.interfaces.calIErrors;
// Check if it is worth enumerating all the error codes.
if (aErrNo & calIError.ERROR_BASE) {
for (var err in calIError) {
if (calIError[err] == aErrNo) {
if (aErrNo & calIErrors.ERROR_BASE) {
for (var err in calIErrors) {
if (calIErrors[err] == aErrNo) {
errCode = err;
}
}
}
var message;
switch (aErrNo) {
case calIErrors.CAL_UTF8_DECODING_FAILED:
message = props.GetStringFromName("utf8DecodeError");
break;
case calIErrors.ICS_MALFORMEDDATA:
message = props.GetStringFromName("icsMalformedError");
break;
default:
message = aMessage
}
paramBlock.SetString(0, errMsg);
paramBlock.SetString(1, errCode);
paramBlock.SetString(2, aMessage);
paramBlock.SetString(2, message);
this.storedReadOnly = this.calendar.readOnly;

Просмотреть файл

@ -52,6 +52,7 @@ const calIOperationListener = Components.interfaces.calIOperationListener;
const calICalendar = Components.interfaces.calICalendar;
const calCalendarManagerContractID = "@mozilla.org/calendar/manager;1";
const calICalendarManager = Components.interfaces.calICalendarManager;
const calIErrors = Components.interfaces.calIErrors;
var activeCalendarManager = null;
function getCalendarManager()
@ -190,15 +191,6 @@ calICSCalendar.prototype = {
return;
}
// Create a new calendar, to get rid of all the old events
this.mMemoryCalendar = Components.classes["@mozilla.org/calendar/calendar;1?type=memory"]
.createInstance(Components.interfaces.calICalendar);
this.mMemoryCalendar.uri = this.mUri;
this.mMemoryCalendar.wrappedJSObject.calendarToReturn = this;
this.mMemoryCalendar.addObserver(this.mObserver);
this.mObserver.onStartBatch();
// This conversion is needed, because the stream only knows about
// byte arrays, not about strings or encodings. The array of bytes
// need to be interpreted as utf8 and put into a javascript string.
@ -210,9 +202,20 @@ calICSCalendar.prototype = {
try {
str = unicodeConverter.convertFromByteArray(result, result.length);
} catch(e) {
this.mObserver.onError(e.result, e.toString());
this.mObserver.onError(calIErrors.CAL_UTF8_DECODING_FAILED, e.toString());
this.unlock();
return;
}
// Create a new calendar, to get rid of all the old events
this.mMemoryCalendar = Components.classes["@mozilla.org/calendar/calendar;1?type=memory"]
.createInstance(Components.interfaces.calICalendar);
this.mMemoryCalendar.uri = this.mUri;
this.mMemoryCalendar.wrappedJSObject.calendarToReturn = this;
this.mMemoryCalendar.addObserver(this.mObserver);
this.mObserver.onStartBatch();
// Wrap parsing in a try block. Will ignore errors. That's a good thing
// for non-existing or empty files, but not good for invalid files.
// That's why we put them in readOnly mode

Просмотреть файл

@ -239,6 +239,8 @@ contentError=This doesn't appear to be a valid file. Here's what I got back from
readOnlyMode=There has been an error reading data for calendar: %1$S. It has been placed in read-only mode, since changes to this calendar will likely result in data-loss. You may change this setting by choosing 'Edit Calendar'.
minorError=There has been an error reading data for calendar: %1$S. However, this error is believed to be minor, so the program will attempt to continue.
stillReadOnlyError=There has been an error reading data for calendar: %1$S.
utf8DecodeError=An error occured while decoding an iCalendar (ics) file as UTF-8. Check that the file, including symbols and accented letters, is encoded using the UTF-8 character encoding.
icsMalformedError=Parsing an iCalendar (ics) file failed. Check that the file conforms to iCalendar (ics) file syntax.
# LOCALIZATION NOTE (likelyTimezone):
# Translators, please put the most likely timezone that the people using your