Chase.CrashReporter
0.0.1
dotnet add package Chase.CrashReporter --version 0.0.1
NuGet\Install-Package Chase.CrashReporter -Version 0.0.1
<PackageReference Include="Chase.CrashReporter" Version="0.0.1" />
paket add Chase.CrashReporter --version 0.0.1
#r "nuget: Chase.CrashReporter, 0.0.1"
// Install Chase.CrashReporter as a Cake Addin #addin nuget:?package=Chase.CrashReporter&version=0.0.1 // Install Chase.CrashReporter as a Cake Tool #tool nuget:?package=Chase.CrashReporter&version=0.0.1
Chase.CrashReporter C# Library API Documentation
The Chase.CrashReporter is a C# library for reporting and handling crash events in your application.
Installation
This is not a part of this documentation. Please follow the official library installation instructions.
How to Use
Initializing
First, you need to setup the CrashReport.Reporter
. Here is an example on how to do it:
using Chase.CrashReporter;
CrashReport.Reporter = CrashHandleBuilder.Create()
.WriteToFile("crash-reports") // The directory to store crash reports.
.IncludeStackTrace() // This will include the stack trace in the crash report.
.UseApplicationName("Your Application Name")
.UseApplicationVersion(new Version(1, 0, 0, 0))
.WriteToConsole()
.WriteToDebug()
.UseGithubRepository("YourGithubUsername", "YourGithubRepository")
.UseProcessHandles()
.Build();
The CrashHandleBuilder
is used to configure the way that crash reports will be generated and handled by the application.
Lets break down each part:
WriteToFile(directoryPath)
: This specifies the directory where the crash reports will be stored. If the directory does not already exist, it will be created..WriteToFile("crash-reports")
IncludeStackTrace()
: This will include the stack trace into crash report which can help a lot when debugging..IncludeStackTrace()
UseApplicationName(appName)
: This will set the application name in the crash report which can be helpful especially for end users to know which application caused the issue..UseApplicationName("Example")
UseApplicationVersion(versionNumber)
: This will include the application version in the crash report which can be essential for debugging, especially when multiple versions of a software are in use..UseApplicationVersion(new Version(1, 0, 0, 0))
WriteToConsole()
: This will write the crash report to the console. It can prove to be helpful for debugging purposes, especially in a development environment where console output can easily be viewed..WriteToConsole()
WriteToDebug()
: This will write the crash report to the debug log. Again, this is probably more beneficial for a developer running the software in a debug mode from a development environment..WriteToDebug()
UseGithubRepository(userName, repoName)
: This will link the GitHub repository in the crash report, e.g. for creating issues or bug reports..UseGithubRepository("Drew-Chase", "Chase.CrashReporter")
UseProcessHandles()
: This will hook the crash reporter to catch unhandled exceptions. It provides a standard way for applications to handle unpredicted or fatal errors..UseProcessHandles()
Build()
: This will finalize~~~~ the configuration and build the crash reporter..Build()
All these configurations are optional and can be used according to application needs. The settings set up here will be applied for all the forthcoming crash reports, unless changed.
Reporting a Crash
You can report crash events manually as shown in the example below:
using System.IO;
// Report an IOError exception.
CrashReport.Report(new IOException("An error occurred while reading the file."));
// Report a null exception.
CrashReport.Report(null);
// Report a null exception and exit the application with an exit code of 89.
CrashReport.ReportAndExit(exception: null, exitCode: 89);
Crashes that go unhandled will automatically generate a crash report if the UseProcessHandles
option is present. For instance, when trying to read from a non-existent file:
using System.IO;
File.ReadAllText("non-existent-file.txt");
This will generate a crash report.
Please note that these examples are for demonstration purposes only, as including a null
exception or forcing an error would not make sense in a production setting.
Fetching the Crash Reports
Crash reports generated by Chase.CrashReporter can be fetched from the directory that you have specified while initializing CrashHandleBuilder
if no directory was specified it will default to the path of the executable.
Contributing
To contribute to the project, please follow the guidelines mentioned in the GitHub repository of the project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 127 | 5/18/2024 |
Initial Release