Skip to content

Doc: add error handling with try catch to readme example #570

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,28 @@ The examples below show how to have your application initiate and outbound phone
```csharp
TwilioClient.Init("ACCOUNT_SID", "AUTH_TOKEN");

var call = CallResource.Create(
try {
var call = CallResource.Create(
new PhoneNumber("+11234567890"),
from: new PhoneNumber("+10987654321"),
url: new Uri("https://my.twiml.here")
);
url: new Uri("https://my.twiml.here"));
} catch (ApiException e) {
Console.WriteLine(e.Message);
Console.WriteLine($"Twilio Error {e.Code} - {e.MoreInfo}");
}

Console.WriteLine(call.Sid);

var message = MessageResource.Create(
try {
var message = MessageResource.Create(
new PhoneNumber("+11234567890"),
from: new PhoneNumber("+10987654321"),
body: "Hello World!"
);
body: "Hello World!");
} catch (ApiException e) {
Console.WriteLine(e.Message);
Console.WriteLine($"Twilio Error {e.Code} - {e.MoreInfo}");
}

Console.WriteLine(message.Sid);
```

Expand Down