StacktraceGpt.Server (stacktrace_gpt v0.1.2)
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
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.
ask_gpt()
@spec ask_gpt() :: :ok | :nothing_to_ask
Gets the last message from the ETS table and asks GPT for explanation.
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
clear_stacktrace()
@spec clear_stacktrace() :: true
Clears the ETS table.
init(_)
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.
start_link(_)
Initiates the server process. It is linked to the current process and can be identified by the module name.