Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete/Missing error handling in NewMessageModal.onSend #9840

Open
kesselb opened this issue Jul 11, 2024 · 0 comments
Open

Incomplete/Missing error handling in NewMessageModal.onSend #9840

kesselb opened this issue Jul 11, 2024 · 0 comments

Comments

@kesselb
Copy link
Contributor

kesselb commented Jul 11, 2024

Steps to reproduce

  1. Write an email
  2. Click send
  3. An error, from the backend, is not properly handled

Expected behavior

As a User, I expected a hint/warning when something went wrong.

Actual behavior

Nothing.

To do

  • Remove dead code
  • Show a warning when the backend operation failed

Additional info

} catch (error) {
logger.error('could not send message', { error })
this.error = await matchError(error, {
[NoSentMailboxConfiguredError.getName()]() {
return t('mail', 'No sent mailbox configured. Please pick one in the account settings.')
},
[ManyRecipientsError.getName()]() {
return t('mail', 'You are trying to send to many recipients in To and/or Cc. Consider using Bcc to hide recipient addresses.')
},
// eslint-disable-next-line n/handle-callback-err
default(error) {
return undefined
},
})
this.warning = await matchError(error, {
[AttachmentMissingError.getName()]() {
return t('mail', 'You mentioned an attachment. Did you forget to add it?')
},
// eslint-disable-next-line n/handle-callback-err
default(error) {
return undefined
},
})
} finally {
this.sending = false
}

  • NoSentMailboxConfiguredError and ManyRecipientsError are mapped from the backend exceptions1, but the backend does not throw SentMailboxNotSetException and ManyRecipientsException anymore.
  • The phpdoc for IMailTransmission.sendMessage is outdated.
  • NewMessageModal.onSend may put a draft into the outbox without having a draft saved already (1), update a message in the outbox (2), update an existing draft and put it into the outbox (3).

To simulate a failure for case 1 or 3:

Index: lib/Controller/OutboxController.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
< >UTF-8
===================================================================
diff --git a/lib/Controller/OutboxController.php b/lib/Controller/OutboxController.php
--- a/lib/Controller/OutboxController.php	(revision 2cfa6995f9de4d356a28e32c4f12ccf74a679717)
    b/lib/Controller/OutboxController.php	(date 1720696979685)
@@ -145,6  145,8 @@
		// Locate the account to check authorization
		$this->accountService->find($this->userId, $draftMessage->getAccountId());

 		throw new ClientException('Computer says no');
 
		$outboxMessage = $this->service->convertDraft($draftMessage, $sendAt);

		return JsonResponse::success(
Screencast.from.2024-07-11.13-24-49.webm

There's no feedback that something went wrong, I'm just taking back to the composer, and it says, "Draft saved".

Footnotes

  1. https://github.com/nextcloud/mail/blob/c1d14c4fa32f8d66543db9dc2402d5914127d7d8/src/errors/convert.js#L15-L24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants