- Added JS debug lib

This commit is contained in:
Dave M. 2024-03-13 09:08:37 -04:00
parent 3590993925
commit ef43c7831f
4 changed files with 69 additions and 0 deletions

46
asset/negundo/js/debug.js Normal file
View File

@ -0,0 +1,46 @@
class ErrorHandler
{
constructor(options) {
if ( options ) {
if ( "url" in options ) {
this.url = options['url'];
}
}
this.catchError();
}
catchError() {
window.onerror = function(message, url, line, column, error) {
fetch(this.url ? this.url : window.location.href, {
method: "post",
headers: {
'Accept': "application/json",
'Content-Type': "application/json",
'User-Agent': "NegundoClient/1.0"
},
body: JSON.stringify({
message: message,
url: url,
line: line,
column: column,
stack: error.stack,
location: window.location.toString()
})
}).then( response => response ).then(data => {
console.info("Error reported", data);
});
return false;
}.bind(this);
}
get url() {
return this._url;
}
set url(set) {
return this._url = set;
}
}

View File

@ -25,6 +25,9 @@
"autoload": { "autoload": {
"definitions" : [ "definitions" : [
"meta/negundo.php" "meta/negundo.php"
],
"config": [
"meta/config.php"
] ]
} }
} }

9
meta/config.php Normal file
View File

@ -0,0 +1,9 @@
<?php
return [
'lean' => [
'autoload' => [
'assets.negundo'
]
],
];

View File

@ -9,4 +9,15 @@ return [
NegundoMiddleware::class => autowire(NegundoMiddleware::class), NegundoMiddleware::class => autowire(NegundoMiddleware::class),
Dump::class => autowire(Dump::class), Dump::class => autowire(Dump::class),
Task::class => autowire(Task::class), Task::class => autowire(Task::class),
'assets.negundo' => [
'picea' => [
'asset' => [
[
'path' => implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__), "asset", '' ]),
'order' => 10
]
]
],
],
]; ];