2
0
Files
logikonline 74227e94dc sdk: add C# and Java SDK libraries with chunked upload support
Both SDKs provide:
- Full API client for users, repositories, and releases
- Chunked upload with parallel workers
- Progress tracking with speed/ETA
- SHA256 checksum verification
- Comprehensive exception handling

C# SDK (.NET 8.0):
- Modern record types for models
- Async/await pattern throughout
- System.Text.Json serialization

Java SDK (Java 17):
- Standard Maven project
- Jackson for JSON
- HttpClient for HTTP
- ExecutorService for parallel uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:19:17 -05:00

85 lines
2.1 KiB
C#

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
namespace Gitea.SDK;
/// <summary>
/// Base exception for all Gitea SDK errors.
/// </summary>
public class GiteaException : Exception
{
public GiteaException(string message) : base(message) { }
public GiteaException(string message, Exception inner) : base(message, inner) { }
}
/// <summary>
/// Thrown when authentication fails (401).
/// </summary>
public class AuthenticationException : GiteaException
{
public AuthenticationException(string message) : base(message) { }
}
/// <summary>
/// Thrown when a resource is not found (404).
/// </summary>
public class NotFoundException : GiteaException
{
public NotFoundException(string message) : base(message) { }
}
/// <summary>
/// Thrown when the API returns an error response.
/// </summary>
public class ApiException : GiteaException
{
public string? Code { get; }
public int StatusCode { get; }
public ApiException(string message, string? code, int statusCode)
: base(message)
{
Code = code;
StatusCode = statusCode;
}
}
/// <summary>
/// Thrown when an upload operation fails.
/// </summary>
public class UploadException : GiteaException
{
public string? SessionId { get; }
public int? ChunkNumber { get; }
public UploadException(string message, string? sessionId = null, int? chunkNumber = null)
: base(message)
{
SessionId = sessionId;
ChunkNumber = chunkNumber;
}
public UploadException(string message, Exception inner, string? sessionId = null, int? chunkNumber = null)
: base(message, inner)
{
SessionId = sessionId;
ChunkNumber = chunkNumber;
}
}
/// <summary>
/// Thrown when checksum verification fails.
/// </summary>
public class ChecksumException : UploadException
{
public string? Expected { get; }
public string? Actual { get; }
public ChecksumException(string message, string? expected = null, string? actual = null, string? sessionId = null)
: base(message, sessionId)
{
Expected = expected;
Actual = actual;
}
}