git2dart throws Dart exceptions for invalid Dart-side input and libgit2 failures.
import 'package:git2dart/git2dart.dart';LibGit2Erroris thrown when libgit2 returns an error code. The type is defined by thegit2dart_binariespackage that provides the native bindings.Git2DartErroris thrown by Dart-side wrappers for package-level validation, such as out-of-bounds access in iterable wrappers.ArgumentErroris thrown for invalid Dart arguments before libgit2 is called.
try {
final oid = Oid.fromSHA(repo, '0000000');
final blob = Blob.lookup(repo: repo, oid: oid);
print(blob.content);
} on ArgumentError catch (error) {
print('Invalid input: $error');
} on Git2DartError catch (error) {
print('git2dart failed: $error');
} catch (error) {
print('Git operation failed: $error');
}Git2DartError.toString() returns the message, and stackTrace is available
for diagnostics.
Use the options shown in the example for this API. Related enum and flag details are collected in Shared Git enums and options.
Error types do not own native resources. Catch ArgumentError for invalid Dart input and catch broader Git operation failures around libgit2 calls.