Spaces:
Sleeping
Sleeping
Scott Hiett
commited on
Commit
·
db4111e
1
Parent(s):
88a54bd
Error handling for invalid redis commands
Browse files
lib/srh/http/command_handler.ex
CHANGED
@@ -26,8 +26,19 @@ defmodule Srh.Http.CommandHandler do
|
|
26 |
case GenRegistry.lookup_or_start(Client, srh_id, [max_connections, connection_info]) do
|
27 |
{:ok, pid} ->
|
28 |
# Run the command
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
{:error, msg} ->
|
32 |
{:server_error, msg}
|
33 |
end
|
|
|
26 |
case GenRegistry.lookup_or_start(Client, srh_id, [max_connections, connection_info]) do
|
27 |
{:ok, pid} ->
|
28 |
# Run the command
|
29 |
+
case Client.redis_command(pid, command_array) do
|
30 |
+
{:ok, res} ->
|
31 |
+
{:ok, %{result: res}}
|
32 |
+
{:error, error} ->
|
33 |
+
{
|
34 |
+
:malformed_data,
|
35 |
+
Jason.encode!(
|
36 |
+
%{
|
37 |
+
error: error.message
|
38 |
+
}
|
39 |
+
)
|
40 |
+
}
|
41 |
+
end
|
42 |
{:error, msg} ->
|
43 |
{:server_error, msg}
|
44 |
end
|
lib/srh/redis/client_worker.ex
CHANGED
@@ -27,10 +27,6 @@ defmodule Srh.Redis.ClientWorker do
|
|
27 |
when is_pid(redix_pid) do
|
28 |
case Redix.command(redix_pid, command_array) do
|
29 |
{:ok, res} ->
|
30 |
-
IO.puts("Worker PID:")
|
31 |
-
IO.inspect(self())
|
32 |
-
IO.puts("Worker Redis response:")
|
33 |
-
IO.inspect(res)
|
34 |
{:reply, {:ok, res}, state}
|
35 |
|
36 |
{:error, res} ->
|
|
|
27 |
when is_pid(redix_pid) do
|
28 |
case Redix.command(redix_pid, command_array) do
|
29 |
{:ok, res} ->
|
|
|
|
|
|
|
|
|
30 |
{:reply, {:ok, res}, state}
|
31 |
|
32 |
{:error, res} ->
|