Current section
Files
Jump to
Current section
Files
src/pollux@reason.erl
-module(pollux@reason).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/pollux/reason.gleam").
-export([method_not_available/1, unknown_tool/1, unknown_prompt/1, invalid_log_level/1, invalid_arguments/2, resource_not_found/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/pollux/reason.gleam", 8).
-spec method_not_available(binary()) -> pollux:error_object().
method_not_available(Method) ->
{error_object,
-32601,
<<"Method unavailable: "/utf8, Method/binary>>,
{object, maps:from_list([{<<"method"/utf8>>, {string, Method}}])}}.
-file("src/pollux/reason.gleam", 17).
?DOC(" Used for unknown and unavailable\n").
-spec unknown_tool(binary()) -> pollux:error_object().
unknown_tool(Tool) ->
{error_object,
-32602,
<<"Unknown tool: "/utf8, Tool/binary>>,
{object, maps:from_list([{<<"tool"/utf8>>, {string, Tool}}])}}.
-file("src/pollux/reason.gleam", 25).
-spec unknown_prompt(binary()) -> pollux:error_object().
unknown_prompt(Prompt) ->
{error_object,
-32602,
<<"Unknown prompt: "/utf8, Prompt/binary>>,
{object, maps:from_list([{<<"prompt"/utf8>>, {string, Prompt}}])}}.
-file("src/pollux/reason.gleam", 33).
-spec invalid_log_level(binary()) -> pollux:error_object().
invalid_log_level(Level) ->
{error_object,
-32602,
<<"Invalid log level: "/utf8, Level/binary>>,
{object, maps:from_list([{<<"level"/utf8>>, {string, Level}}])}}.
-file("src/pollux/reason.gleam", 41).
-spec invalid_arguments(binary(), list(gleam@dynamic@decode:decode_error())) -> pollux:error_object().
invalid_arguments(Tool, Decode) ->
Reason = begin
_pipe = gleam@list:map(
Decode,
fun(Error) ->
{decode_error, Expected, Found, Path} = Error,
{object,
maps:from_list(
[{<<"expected"/utf8>>, {string, Expected}},
{<<"found"/utf8>>, {string, Found}},
{<<"path"/utf8>>,
{string, gleam@string:join(Path, <<"."/utf8>>)}}]
)}
end
),
{array, _pipe}
end,
{error_object,
-32602,
<<"Invalid arguments for tool: "/utf8, Tool/binary>>,
{object,
maps:from_list(
[{<<"tool"/utf8>>, {string, Tool}}, {<<"reason"/utf8>>, Reason}]
)}}.
-file("src/pollux/reason.gleam", 63).
-spec resource_not_found(binary()) -> pollux:error_object().
resource_not_found(Uri) ->
{error_object,
-32002,
<<"Resource not found"/utf8>>,
{object, maps:from_list([{<<"uri"/utf8>>, {string, Uri}}])}}.