Implement system-wide error logging with automatic deduplication and MCCoroutine integration#10
Conversation
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
…anup Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
|
@copilot this is for mccorountine Exception Handling If an exception is not caught (e.g. an exception is thrown in a suspendable commandexecutor or listener), the exception is propagated upwards to MCCoroutine. Default Exception Behaviour logger.log( The event arrives at the main thread in Bukkit, Sponge, Minestom. In Folia, it arrives on the globalRegionThread. |
…error handling Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Implemented MCCoroutine exception handling. Added
The listeners are registered in Commit: 582d5d8 |
|
@copilot remove the IMPLMENTATION SUMMRARY UND SYSTEM ERROR LOGGING MD |
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
…structure' into copilot/implement-error-logging-structure
|
@copilot /testerror coroutine seem not working |
…gin check to listener Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Fixed the issue. The Also added back the plugin check in the listener to only handle exceptions from our plugin. Commit: 043b624 |
|
@copilot when an error is shown in the console, the internal error id should also be there with a message "This error has been logged. |
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Added error ID logging to console. When an error is captured by any handler (GlobalErrorHandler, MCCoroutineExceptionListener), the console now displays:
This allows admins to easily reference the error using Commit: 2fa1c5a |
|
@copilot duplicate errors are logged multiple times if a restart is between |
|
@copilot remove all comments made by you |
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Fixed deduplication across restarts. The issue was that the previous implementation used a SELECT-then-INSERT/UPDATE pattern, which had a race condition. Now using database
Commit: dfdf5a6 |
I don't have the ability to delete PR comments through the available tools. GitHub comments can only be deleted manually through the GitHub web interface by users with the appropriate permissions. You can delete comments by:
|
|
@copilot delete the comments in your code |
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
|
@copilot rename "System Error" related stuff to "SurfCoreSystemError" |
Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Renamed all "SystemError" related components to "SurfCoreSystemError": Files renamed:
All references updated throughout the codebase including GlobalErrorHandler, MCCoroutineExceptionListener (Paper & Velocity), DatabaseLoaderImpl, and PaperMain. Commit: c8267fe |
…rvice implementations
Error Logging System Implementation - Complete ✅
Requirements Fulfilled
✅ Set custom error handler on every thread - Implemented via
GlobalErrorHandler.install()which setsThread.setDefaultUncaughtExceptionHandler()✅ Set custom error handler in MCCoroutine/coroutine scopes - Implemented via
MCCoroutineExceptionListenerwhich listens toMCCoroutineExceptionEventfor all coroutines managed by MCCoroutine✅ Error deduplication with lastOccurred - Errors with identical (message + location + server) update
lastOccurredand incrementoccurrenceCountinstead of creating duplicates. Uses atomic upsert operation to ensure deduplication works across restarts.✅ Comprehensive error data - Each error includes:
locationfield (ClassName.methodName:lineNumber)firstOccurredandlastOccurredtimestampserrorMessageand fullstacktraceoccurrenceCountfor tracking frequency✅ Separate table, repository, and service structure - Complete implementation independent from player error logging
Components Implemented
11 New Files Created:
SurfCoreSystemErrordata class (API)SurfCoreSystemErrorTable(Database schema with unique index, table:surf_core_system_errors)SurfCoreSystemErrorRepository(Data access with atomic upsert-based deduplication)SurfCoreSystemErrorServiceinterface and implementationGlobalErrorHandler(Error capture with lifecycle management)MCCoroutineExceptionListenerfor Paper (Listens to MCCoroutine exceptions)MCCoroutineExceptionListenerfor Velocity (Listens to MCCoroutine exceptions)SurfCoreSystemErrorCommand(/surfcoresystemerror list/view commands)TestErrorCommand(/testerror test scenarios)4 Files Modified:
DatabaseLoaderImpl- Register SurfCoreSystemErrorTablePaperMain- Install handler, register listeners, add shutdownVelocityMain- Install handler, register listeners, add shutdownKey Features
MCCoroutine Integration
Following MCCoroutine best practices:
MCCoroutineExceptionEventfor all coroutine exceptionsCancellationException(thrown when jobs are cancelled)Error Logging Output
When an error is captured, the console displays:
Deduplication Behavior
The system uses a unique database index on (errorMessage, location, server) combined with upsert operations to ensure:
firstOccurredtimestamp is preserved from the original errorlastOccurredtimestamp is updated to the most recent occurrenceoccurrenceCountis incremented for each occurrencestacktraceis updated to reflect the most recent occurrenceTesting
Use
/testerrorcommand to validate:/testerror thread- Test thread exception capture/testerror coroutine- Test MCCoroutine exception capture/testerror manual- Test manual error logging/testerror duplicate- Test deduplication (triggers 3x, logs 1x)View errors with:
/surfcoresystemerror list- Paginated error list/surfcoresystemerror view <id>- Detailed error viewOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.