-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c76f67
commit 58aa429
Showing
4 changed files
with
52 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace matrix_dotnet; | ||
|
||
public class LoginRequiredException : UnauthorizedAccessException { } | ||
|
||
public class MatrixApiError : Exception { | ||
public string ErrorCode { get; } | ||
public string ErrorMessage { get; } | ||
public HttpResponseMessage Response { get; } | ||
|
||
public MatrixApiError(string errorCode, string errorMessage, HttpResponseMessage response, Exception? innerException) | ||
: base(String.Format("Request to Matrix API failed: {0}: {1}", errorCode, errorMessage), innerException) { | ||
ErrorCode = errorCode; | ||
ErrorMessage = errorMessage; | ||
Response = response; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace matrix_dotnet; | ||
|
||
class Retry { | ||
public class RetryException : Exception {} | ||
|
||
public static async Task<TResult> RetryAsync<TResult>(Func<Task<TResult>> func) { | ||
retry: | ||
try { | ||
return await func(); | ||
} catch (RetryException) { | ||
goto retry; | ||
} | ||
} | ||
} | ||
|