mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 16:40:41 +00:00
doc: move/clean ErrorService
Some documentation comments were missing or inaccurate so these were also edited after moving.
This commit is contained in:
@@ -87,7 +87,6 @@ const install = async ({ services, app, useapi, modapi }) => {
|
||||
// in a future PR.
|
||||
|
||||
const { PagerService } = require('./services/runtime-analysis/PagerService');
|
||||
const { ErrorService } = require('./services/runtime-analysis/ErrorService');
|
||||
const { CommandService } = require('./services/CommandService');
|
||||
const { ExpectationService } = require('./services/runtime-analysis/ExpectationService');
|
||||
const { HTTPThumbnailService } = require('./services/thumbnails/HTTPThumbnailService');
|
||||
@@ -144,7 +143,6 @@ const install = async ({ services, app, useapi, modapi }) => {
|
||||
services.registerService('__gui', ServeGUIService);
|
||||
services.registerService('expectations', ExpectationService);
|
||||
services.registerService('pager', PagerService);
|
||||
services.registerService('error-service', ErrorService);
|
||||
services.registerService('registry', RegistryService);
|
||||
services.registerService('__registrant', RegistrantService);
|
||||
services.registerService('fslock', FSLockService);
|
||||
|
||||
@@ -24,6 +24,9 @@ class Core2Module extends AdvancedBase {
|
||||
|
||||
const { AlarmService } = require("./AlarmService.js");
|
||||
services.registerService('alarm', AlarmService);
|
||||
|
||||
const { ErrorService } = require("./ErrorService.js");
|
||||
services.registerService('error-service', ErrorService);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-3
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
const BaseService = require("../BaseService");
|
||||
const BaseService = require("../../services/BaseService");
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,10 +47,11 @@ class ErrorContext {
|
||||
|
||||
|
||||
/**
|
||||
* The ErrorService class is responsible for handling and reporting errors within the system.
|
||||
* It provides methods to initialize the service, create error contexts, and report errors with detailed logging and alarm mechanisms.
|
||||
|
||||
* @class ErrorService
|
||||
* @extends BaseService
|
||||
* @description The ErrorService class is responsible for handling and reporting errors within the system.
|
||||
* It provides methods to initialize the service, create error contexts, and report errors with detailed logging and alarm mechanisms.
|
||||
*/
|
||||
class ErrorService extends BaseService {
|
||||
/**
|
||||
@@ -66,9 +67,27 @@ class ErrorService extends BaseService {
|
||||
this.alarm = services.get('alarm');
|
||||
this.backupLogger = services.get('log-service').create('error-service');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ErrorContext instance with the provided logging context.
|
||||
*
|
||||
* @param {*} log_context The logging context to associate with the error reports.
|
||||
* @returns {ErrorContext} An ErrorContext instance.
|
||||
*/
|
||||
create (log_context) {
|
||||
return new ErrorContext(this, log_context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports an error with the specified location and details.
|
||||
* The "location" is a string up to the callers discretion to identify
|
||||
* the source of the error.
|
||||
*
|
||||
* @param {*} location The location where the error occurred.
|
||||
* @param {*} fields The error details to report.
|
||||
* @param {boolean} [alarm=true] Whether to raise an alarm for the error.
|
||||
* @returns {void}
|
||||
*/
|
||||
report (location, { source, logger, trace, extra, message }, alarm = true) {
|
||||
message = message ?? source?.message;
|
||||
logger = logger ?? this.backupLogger;
|
||||
@@ -47,6 +47,36 @@ Method to get an alarm by its ID.
|
||||
|
||||
- **id:** The ID of the alarm to get.
|
||||
|
||||
### ErrorService
|
||||
|
||||
The ErrorService class is responsible for handling and reporting errors within the system.
|
||||
It provides methods to initialize the service, create error contexts, and report errors with detailed logging and alarm mechanisms.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### `init`
|
||||
|
||||
Initializes the ErrorService, setting up the alarm and backup logger services.
|
||||
|
||||
##### `create`
|
||||
|
||||
Creates an ErrorContext instance with the provided logging context.
|
||||
|
||||
###### Parameters
|
||||
|
||||
- **log_context:** The logging context to associate with the error reports.
|
||||
|
||||
##### `report`
|
||||
|
||||
Reports an error with the specified location and details.
|
||||
The "location" is a string up to the callers discretion to identify
|
||||
the source of the error.
|
||||
|
||||
###### Parameters
|
||||
|
||||
- **location:** The location where the error occurred.
|
||||
- **fields:** The error details to report.
|
||||
|
||||
### LogService
|
||||
|
||||
The `LogService` class extends `BaseService` and is responsible for managing and
|
||||
|
||||
Reference in New Issue
Block a user