Skip to content

Problems

Overview

Module

The Problems module provides a static utility class for managing system problems and issues through the platform's ProblemsFacade. It allows developers to save new problems, fetch existing ones, update their status, and delete them as needed. This module abstracts the complexities of problem management, providing a simple interface for handling issues that arise during development or runtime.

Key Features:

  • Problem Recording: Save detailed information about problems, including location, type, cause, and expected outcomes.
  • Problem Retrieval: Fetch individual problems by ID or retrieve all problems with optional filtering and batching.
  • Status Management: Update the status of problems to indicate whether they are active, solved, or ignored.
  • Problem Deletion: Remove specific problems or clear all problems based on their status.

Use Cases:

  • Issue Tracking: This module is ideal for applications that need to track and manage issues that occur during development or runtime, providing a structured way to log and resolve problems.
  • Automated Problem Handling: Developers can use this module to automate the handling of known issues by updating their status or deleting them as part of maintenance routines.

Example Usage:

ts
import { Problems } from "@aerokit/sdk/platform";

// Save a new problem
Problems.save("/path/to/file.js", "Syntax Error", "10", "15", "Unexpected token", "Expected ';'", "Syntax", "JavaScript", "const a = ;", "file.js");

// Fetch all problems
const allProblems = Problems.fetchAllProblems();
console.log("All Problems:", allProblems);

// Update the status of a problem
Problems.updateStatus(1, Problems.SOLVED);

// Delete a specific problem
Problems.deleteProblem(1);

Classes

Problems

save()

Saves a new problem entry to the system's problem log.

ts
static save(location: string, type: string, line: string, column: string, cause: string, expected: string, category: string, module: string, source: string, program: string): void;
ParameterTypeDescription
locationstringThe resource path or file location.
typestringThe severity or nature of the problem.
linestringThe line number.
columnstringThe column number.
causestringThe cause description.
expectedstringThe expected state/value description.
categorystringThe problem category.
modulestringThe module/component name.
sourcestringThe original source content.
programstringThe program or file name.

Returns

  • Type: void
  • Description:

findProblem()

Finds a specific problem by its unique ID. Note: The underlying facade returns a JSON string which is parsed here.

ts
static findProblem(id: number): Problem;
ParameterTypeDescription
idnumberThe unique problem ID.

Returns

  • Type: Problem
  • Description: The found Problem object.

fetchAllProblems()

Fetches all recorded problems in the system. Note: The underlying facade returns a JSON string which is parsed here.

ts
static fetchAllProblems(): void;

Returns

  • Type: void
  • Description: An array of all Problem objects.

fetchProblemsBatch()

Fetches a batch of problems based on a custom condition and limit.

ts
static fetchProblemsBatch(condition: string, limit: number): void;
ParameterTypeDescription
conditionstringA SQL-like condition string (e.g., "CATEGORY='Syntax'").
limitnumberThe maximum number of problems to retrieve.

Returns

  • Type: void
  • Description: An array of Problem objects matching the condition.

deleteProblem()

Deletes a problem record by its unique ID.

ts
static deleteProblem(id: number): void;
ParameterTypeDescription
idnumberThe unique problem ID to delete.

Returns

  • Type: void
  • Description:

deleteAllByStatus()

Deletes all problem records that currently have the specified status.

ts
static deleteAllByStatus(status: string): void;
ParameterTypeDescription
statusstringThe status (e.g., Problems.SOLVED or Problems.IGNORED).

Returns

  • Type: void
  • Description:

clearAllProblems()

Clears (deletes) all problem records in the system, regardless of status.

ts
static clearAllProblems(): void;

Returns

  • Type: void
  • Description:

updateStatus()

Updates the status of a single problem by its ID.

ts
static updateStatus(id: number, status: string): void;
ParameterTypeDescription
idnumberThe unique problem ID.
statusstringThe new status (e.g., Problems.SOLVED).

Returns

  • Type: void
  • Description:

updateStatusMultiple()

Updates the status of multiple problems identified by an array of IDs.

ts
static updateStatusMultiple(ids: any, status: string): void;
ParameterTypeDescription
idsanyAn array of unique problem IDs.
statusstringThe new status to apply to all problems.

Returns

  • Type: void
  • Description: