StacktraceGpt.Server (stacktrace_gpt v0.1.1)

This module is a GenServer that stores stacktraces in an ETS table and facilitates calls to ChatGPT to get explanations of those stacktraces.

Link to this section Summary

Functions

Adds stacktrace message to the ETS table in :dev environment. message - is a string or a cons-cell-like list with an error message inside. The error message inside is extracted in the add_message_to_queue function.

Gets the last message from the ETS table and asks GPT for explanation.

Returns a specification to start this module under a supervisor.

Clears the ETS table.

Initializes the server by logging its start and creating an ETS table named :stacktrace_gpt with protection type :protected. The table is public, uses the set data type, and is named.

Initiates the server process. It is linked to the current process and can be identified by the module name.

Link to this section Functions

Link to this function

add_stacktrace(message, env \\ Mix.env())

@spec add_stacktrace(binary() | list(), atom()) ::
  true | :not_dev_env | :message_format_not_supported

Adds stacktrace message to the ETS table in :dev environment. message - is a string or a cons-cell-like list with an error message inside. The error message inside is extracted in the add_message_to_queue function.

Returns true if successful. Returns :not_dev_env if not in :dev environment. Returns :message_format_not_supported if message is not a binary.

@spec ask_gpt() :: :ok | :nothing_to_ask

Gets the last message from the ETS table and asks GPT for explanation.

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

clear_stacktrace()

@spec clear_stacktrace() :: true

Clears the ETS table.

Initializes the server by logging its start and creating an ETS table named :stacktrace_gpt with protection type :protected. The table is public, uses the set data type, and is named.

Initiates the server process. It is linked to the current process and can be identified by the module name.