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

Update SendGridKit to version 2.0.2 #47

Merged
merged 3 commits into from Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Expand Up @@ -11,7 +11,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "1.0.0"),
.package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "2.0.2"),
],
targets: [
.target(name: "SendGrid", dependencies: [
Expand Down
16 changes: 7 additions & 9 deletions README.md
Expand Up @@ -46,19 +46,17 @@ import SendGrid

let email = SendGridEmail(…)

return req.application.sendgrid.client.send([email], on: req.eventLoop)
try await req.application.sendgrid.client.send(email)
~~~~

## Error handling
If the request to the API failed for any reason a `SendGridError` is the result
of the future, and has an `errors` property that contains an array of errors
returned by the API:

If the request to the API failed for any reason a `SendGridError` is thrown and has an `errors` property that contains an array of errors returned by the API:

~~~~swift
return req.application.sendgrid.client.send([email], on: req.eventLoop).flatMapError { error in
if let sendgridError = error as? SendGridError {
req.logger.error("\(error)")
}
// ...
do {
try await req.application.sendgrid.client.send(email)
} catch let error as SendGridError {
req.logger.error("\(error)")
}
~~~~