From a506fced0d8575dc1cdc153a39de2d0bace1f24d Mon Sep 17 00:00:00 2001 From: Karchnu Date: Sun, 7 Jun 2020 00:52:02 +0200 Subject: [PATCH] Response::Error and Success removed. --- src/common/requests/download.cr | 2 +- src/common/requests/login.cr | 2 +- src/common/requests/transfer.cr | 4 ++-- src/common/requests/upload.cr | 2 +- src/server/main.cr | 2 +- src/server/network.cr | 15 --------------- 6 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/common/requests/download.cr b/src/common/requests/download.cr index 4b8cd40..bb2ff34 100644 --- a/src/common/requests/download.cr +++ b/src/common/requests/download.cr @@ -21,7 +21,7 @@ class FileStorage::Request filestoraged.storage.download self, user_data rescue e - return Response::Error.new @mid, "unauthorized" + return Errors::GenericError.new @mid, e.to_s end end FileStorage.requests << Download diff --git a/src/common/requests/login.cr b/src/common/requests/login.cr index 538534f..afd2669 100644 --- a/src/common/requests/login.cr +++ b/src/common/requests/login.cr @@ -28,7 +28,7 @@ class FileStorage::Request return Response::Login.new @mid rescue e - return Response::Error.new @mid, "unauthorized" + return Errors::GenericError.new @mid, "unauthorized" end end FileStorage.requests << Login diff --git a/src/common/requests/transfer.cr b/src/common/requests/transfer.cr index 95c81a1..01c8808 100644 --- a/src/common/requests/transfer.cr +++ b/src/common/requests/transfer.cr @@ -29,7 +29,7 @@ class FileStorage::Request filestoraged.storage.write_chunk self, user_data rescue e - return Response::Error.new @mid, "unauthorized" + return Errors::GenericError.new @mid, e.to_s end end FileStorage.requests << PutChunk @@ -55,7 +55,7 @@ class FileStorage::Request filestoraged.storage.read_chunk self, user_data rescue e - return Response::Error.new @mid, "unauthorized" + return Errors::GenericError.new @mid, e.to_s end end FileStorage.requests << GetChunk diff --git a/src/common/requests/upload.cr b/src/common/requests/upload.cr index 5828c69..81c9553 100644 --- a/src/common/requests/upload.cr +++ b/src/common/requests/upload.cr @@ -19,7 +19,7 @@ class FileStorage::Request filestoraged.storage.upload self, user_data rescue e - return Response::Error.new @mid, "unauthorized" + return Errors::GenericError.new @mid, e.to_s end end FileStorage.requests << Upload diff --git a/src/server/main.cr b/src/server/main.cr index 700bd55..b650d43 100644 --- a/src/server/main.cr +++ b/src/server/main.cr @@ -157,7 +157,7 @@ class FileStorage::Service < IPC::Service if response.responds_to?(:reason) warning ">> #{response_type.sub /^FileStorage::Errors::/, ""} (#{response.reason})" else - info ">> #{response.class.name.sub /^FileStorage::Response::/, ""}" + info ">> #{response_type.sub /^FileStorage::Response::/, ""}" end ################################################################# diff --git a/src/server/network.cr b/src/server/network.cr index 0a6d422..91fc2c2 100644 --- a/src/server/network.cr +++ b/src/server/network.cr @@ -45,21 +45,6 @@ class FileStorage::Client < IPC::Client end end -class FileStorage::Response - JSONIPC.request Error, 0 do - property mid : String - property reason : String | Array(String) - - def initialize(@mid, @reason) - end - end - JSONIPC.request Success, 1 do - property mid : String - def initialize(@mid) - end - end -end - def parse_message(requests : Array(JSONIPC.class), message : IPC::Message) : JSONIPC? request_type = requests.find &.type.==(message.utype)