Response::Error and Success removed.

This commit is contained in:
Karchnu 2020-06-07 00:52:02 +02:00
parent b4f09f2efd
commit a506fced0d
6 changed files with 6 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
#################################################################

View File

@ -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)