Skip to content

Commit

Permalink
Merge pull request #47 from melgu/SendGridKit-2.0.1
Browse files Browse the repository at this point in the history
Update SendGridKit to version 2.0.2
  • Loading branch information
Andrewangeta authored Jun 26, 2023
2 parents 148eeaf + f2d16e2 commit d74f13e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)")
}
~~~~

0 comments on commit d74f13e

Please sign in to comment.