mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 04:40:54 +00:00
Add default messages for custom exceptions
Right now, our exception messages come from the API response in most cases. But if for any reason there isn't one, we supply a default. I realized these messages might make it to people's logs so it might be nice to spend time later making them even more useful.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Exceptions
|
||||
{
|
||||
public class TwoFactorRequiredExceptionTests
|
||||
{
|
||||
public class TheConstructor
|
||||
{
|
||||
[Fact]
|
||||
public void SetsDefaultMessage()
|
||||
{
|
||||
var response = new ApiResponse<object>
|
||||
{
|
||||
StatusCode = HttpStatusCode.Unauthorized
|
||||
};
|
||||
|
||||
var exception = new TwoFactorRequiredException(response, TwoFactorType.Sms);
|
||||
|
||||
Assert.Equal("Two-factor authentication code is required", exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user