{"id":26678200,"url":"https://github.com/telexintegrations/telex-global-error-handler","last_synced_at":"2025-03-26T05:15:11.411Z","repository":{"id":279076070,"uuid":"937173952","full_name":"telexintegrations/telex-global-error-handler","owner":"telexintegrations","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-23T16:05:21.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-23T16:30:11.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telexintegrations.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T14:11:50.000Z","updated_at":"2025-02-23T16:05:24.000Z","dependencies_parsed_at":"2025-02-23T16:40:20.521Z","dependency_job_id":null,"html_url":"https://github.com/telexintegrations/telex-global-error-handler","commit_stats":null,"previous_names":["telexintegrations/telex-global-error-handler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-global-error-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-global-error-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-global-error-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex-global-error-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telexintegrations","download_url":"https://codeload.github.com/telexintegrations/telex-global-error-handler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245591533,"owners_count":20640692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T05:15:09.899Z","updated_at":"2025-03-26T05:15:11.405Z","avatar_url":"https://github.com/telexintegrations.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Telex Global Error Handling Integration\n\n## Overview\nThis integration provides a **global error-handling mechanism** for ASPNET Core applications using the **Telex platform**. It ensures that errors are captured, formatted, and logged in your Telex channel in a structured way, improving observability and debugging.\n\n---\n\n## 1. Setting Up Telex Integration\n\nTo begin using the global error-handling integration, follow these steps to configure it within your **Telex organization**.\n\n### **Step 1: Activate the Integration**\n1. Navigate to your **Telex Organisation**.\n2. Go to the **Add Integrations** section.\n3. Use the deployed url of the integration json file below to add the integration to your organization.\n`https://global-error-handler-latest.onrender.com/api/v1/telex-global-error-handler/integration.json`\n\n4. Locate **Global Error Handler** and **Activate** for your channel.\n5. Provide the necessary configuration settings:\n   - **Include InnerException:** `true`\n   - **Include Stack Trace:** `true`\n   - **Max-Length for Stack Trace:** `200` or **Leave it empty** for full length.\n6. Save your settings.\n\n### **Step 2: Test the Integration**\nThe deployed API provides an endpoint to simulate errors:\n\n**GET Request URL:**\n```sh\nhttps://global-error-handler-latest.onrender.com/api/v1/telex-global-error-handler/simulate-error\n```\nMake a GET request to trigger an error and verify that it is logged correctly.\n\n---\n\n## 2. Project Structure\n\n```\n/telex-global-error-handler\n│── GlobalErrorHandlerIntegration/              # Main project folder \n|   ├── Helpers/ \n|   |   ├── TelexSettings.cs              # Contains an auto implemented property for the webhook url configuration.\n|   |   |\n│   ├── Middleware/                   # Contains the global error-handling middleware  \n│   │   ├── TelexGlobalExceptionMiddleware.cs  \n│   │   |\n│   ├── Models/                       # Defines error models and response structures  \n│   │   ├── ErrorDetails.cs  \n│   │   ├── ErrorFormatPayload.cs \n|   |   ├── Setting\n|   |   |\n|   ├── IServices/\n|   ├── ├── ITelexErrorLogger.cs       # Defined the methods responsible for sending and formatting error logs to Telex\n|   |   |\n│   ├── Services/                       \n│   │   ├── TelexErrorLogger.cs        # Implements the methods responsible for sending and formatting error logs to Telex\n│   │   |\n│   ├── appsettings.json               # Application settings (Webhook, logging config, etc.)  \n│   ├── Program.cs                     # Entry point for the application  \n│   ├── GlobalErrorHandlerIntegration.csproj  # Project file  \n│                              \n│── README.md                          # Documentation  \n│── .gitignore                         # Git ignore file  \n│── Dockerfile                         # Deployment configuration  \n│── telex-global-error-handler.sln     # Solution file  \n\n```\n\n## 3. Installing the Project\nSince this application is still in develpment stage, it is not yet a NuGet package, you will need to manually clone the repository and integrate it into your project.\n\n### **Step 1: Clone the Repository**\nRun the following command in your terminal:\n\n```sh\ngit clone https://github.com/telexintegrations/telex-global-error-handler.git\n```\n\n### **Step 2: Add the Project to Your Solution**\n1. Navigate to your ASP.NET Core solution.\n2. Open the `Solution Explorer` in Visual Studio.\n3. Right-click on your solution and select **Add \u003e Existing Project**.\n4. Once successful, locate the `TelexGlobalErrorHandler.csproj` file inside the cloned repository and add it to your solution.\n\n### **Step 4: Reference the Project in Your Application**\nModify your application's `.csproj` file to include a reference to the Telex Global Error Handling project:\n\n```xml\n\u003cItemGroup\u003e\n  \u003cProjectReference Include=\"path\\to\\telex-global-error-handler\\GlobalErrorHandlerIntegration.csproj\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n---\n\n## 5 Configuring the Middleware\n\nTo ensure your application captures errors globally and reports them to Telex, you must configure the middleware in your **request pipeline**.\n\n### **Step 1: Configure `appsettings.json`**\nAdd the following settings to your `appsettings.json` file:\n\n```json\n{\n  \"TelexSettings\": {\n    \"WebhookUrl\": \"https://your-telex-webhook-url.com\"\n  }\n}\n```\n\n### **Step 2: Register the Middleware**\nModify `Program.cs` (for .NET 6+ projects) to include the middleware:\n\n```csharp\nusing GlobalErrorHandlerIntegration.Middlewares; // import the Middleware\nusing GlobalErrorHandlerIntegration.IServices;  // import the IServices\nusing GlobalErrorHandlerIntegration.Services;  // import the Services\nusing GlobalErrorHandlerIntegration.Helpers;  // import the Helper\n\nvar builder = WebApplication.CreateBuilder(args);\n\n// Configure Telex webhook url\nbuilder.Services.Configure\u003cTelexSettings\u003e(builder.Configuration.GetSection(\"TelexSettings\"));\n\n// Register Telex Logger Service http client\nbuilder.Services.AddHttpClient\u003cITelexErrorLogger, TelexErrorLogger\u003e(); // register httpclient before singleton\n// Register Telex error logging services\nbuilder.Services.AddSingleton\u003cITelexErrorLogger, TelexErrorLogger\u003e();\n\nvar app = builder.Build();\n\n// Add Telex global error handling middleware\napp.UseMiddleware\u003cTelexGlobalExceptionMiddleware\u003e();\n\napp.Run();\n```\n---\n\nIt is important to note that you are not to interact directly with any of these classes and methods as they are already implemented and integrated into the middleware.\nYour job is to ensure that you have added a reference to `GlobalErrorHandlerIntegration` in your application project to use its services.\nThen configure the middleware in the request pipeline (program.cs) of your application as shown in the previous steps, and watch the Error handler do its work.\n\n---\n\n## 6. Testing the Integration\n\nOnce your integration is active in the telex channel and the project is correctly referenced, follow these steps to test the setup:\n\n### **Test 1: Trigger an Error in Your Application**\nIntroduce an error in your application and verify that it is logged correctly.\n\n### **Test 2: Check Your Logs**\nEnsure structured error messages are recorded in your logs.\n\n### **Test 3: Verify in Telex Dashboard**\nCheck your Telex dashboard to confirm errors are reported properly.\n\n### **Test 4: Simulate an Error Using the API**\nTo test error handling manually without embedding it into your project, send a GET request to the error simulation endpoint:\n\n```sh\ncurl -X GET https://global-error-handler-latest.onrender.com/api/v1/telex-global-error-handler/simulate-error\n```\nHere is a screenshot of the integration working in a channel\n\n### Screenshot 1 (The raw error message which has not been formatted)\n![Integration Test Screenshot 1](https://res.cloudinary.com/dlu45noef/image/upload/v1740324613/Screenshot_2025-02-22_164649_pyeekg.png)\n\n### Screenshot 2 (The formatted error message)\n![Integration Test Screenshot 2](https://res.cloudinary.com/dlu45noef/image/upload/v1740324612/Screenshot_2025-02-22_164750_aq0kte.png)\n\nEnsure that your output matches the expected results as seen in the screenshots.\n\n---\n\n## **7. Deployment**  \nThe integration is hosted on **Render** using a **Docker image**. To ensure it works as expected, an endpoint is provided to simulate errors and verify the logging process.\n\n# Base Url  \n👉 **`https://global-error-handler-latest.onrender.com/api/v1`**  \n\n### **Testing the Deployment**  \nRemember that to test if the integration successfully catches and logs errors in isolation, you can make an http request to the error simulation endpoint:  \n```sh\nGET https://global-error-handler-latest.onrender.com/api/v1/telex-global-error-handler/simulate-error\n```     \n\nThis should trigger an error and log it in your Telex channel.\n\n---\n\n## Conclusion\nBy following these steps, you can seamlessly integrate Telex’s global error-handling capabilities into your application, improving debugging and observability. 🚀\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Ftelex-global-error-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelexintegrations%2Ftelex-global-error-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Ftelex-global-error-handler/lists"}