mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
improve monitoring the solution
This commit is contained in:
+42
@@ -62,3 +62,45 @@ platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
defineCustomElements(window);
|
||||
|
||||
console.log(environment.version.lastCommitTime)
|
||||
|
||||
// error-capture.js
|
||||
|
||||
// Function to capture error details
|
||||
function captureError(message, sourceURL, lineno, colno, error) {
|
||||
const errorDetails = {
|
||||
message: message || 'Unknown error',
|
||||
sourceURL: sourceURL || 'Unknown source',
|
||||
lineNumber: lineno || 'Unknown line',
|
||||
columnNumber: colno || 'Unknown column',
|
||||
stack: error ? error.stack : 'No stack trace'
|
||||
};
|
||||
|
||||
// Log to console
|
||||
console.error('Error Details:', JSON.stringify(errorDetails, null, 2));
|
||||
|
||||
// Optionally, send to server or write to a local storage
|
||||
// Example: Sending to server (requires server-side handling)
|
||||
// fetch('/log-error', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// },
|
||||
// body: JSON.stringify(errorDetails)
|
||||
// });
|
||||
|
||||
// Example: Storing in localStorage
|
||||
// localStorage.setItem('errorLog', JSON.stringify(errorDetails));
|
||||
}
|
||||
|
||||
// Capture errors from synchronous code
|
||||
window.onerror = function(message, sourceURL, lineno, colno, error) {
|
||||
captureError(message, sourceURL, lineno, colno, error);
|
||||
// Return true to prevent default handling (optional)
|
||||
return true;
|
||||
};
|
||||
|
||||
// Capture errors from promise rejections
|
||||
window.addEventListener('unhandledrejection', function(event) {
|
||||
const { reason } = event;
|
||||
captureError(reason.message || 'Unhandled rejection', 'Unknown source', 'Unknown line', 'Unknown column', reason);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user