Open Bug 1504002 Opened 7 years ago Updated 3 years ago

canceling delete of a message throws JS error

Categories

(Thunderbird :: Mail Window Front End, defect)

defect

Tracking

(Not tracked)

People

(Reporter: aceman, Unassigned)

Details

If I try to delete a message in a folder and the confirmation dialog appears (when you don't have that one disabled), you can click Cancel to abort the deletion. This produces an exception in the Error console as if a fatal problem happened. This does not sound correct, as there is no real problem. An error occurred executing the cmd_delete command: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgDBView.doCommand]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://messenger/content/folderDisplay.js :: FolderDisplayWidget_doCommand :: line 1844" data: no] globalOverlay.js:83
Can you fix it?

But I think we want an error, if the messages weren't removed.
The problem is the returned error is very generic and thus we can't catch and hide it.
If we could change it to something like NS_MSG_ERROR_COPY_FOLDER_ABORTED (or define a new proper error), then maybe we could do as in bug 696186, hide the exception from the UI, but keep it for other callers (which would want to know the error (cancelling) happened).

In general throwing should be avoided when you can. You could just have it return true for went trough with delete, and false for not. But seems like very few callers even care.

It returns a nsresult as is the norm. Which is translated to an exception when called from JS, as usual.
How would you return the true/false? Any sample method that already does that?

You'd change the IDL https://searchfox.org/comm-central/rev/258c28a105511491efbfc274a392e90d82eeefce/mailnews/db/msgdb/public/nsIMsgDatabase.idl#420 to be

boolean deleteMessages(in Array<nsMsgKey> nsMsgKeys, in nsIDBChangeListener instigator);

Of course in cpp that just translates to setting a boolean out param.

Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.