active_remote 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6b64877fd4a35dfe8184b73aa07cd8d6ec2673a
4
- data.tar.gz: 971b60a4a6b960c116b5e6429a83bb935bc12e5b
3
+ metadata.gz: 3d760866cbe3d6f0cacdf06891814483c95ed63d
4
+ data.tar.gz: 25892d899421ca22630b5d1323296656bc2efba1
5
5
  SHA512:
6
- metadata.gz: 9149a9dbd69a18e35046e2639b8efea81ab7b4ba7835b9dd9ad6e455695d7b848e6072e05da87b2e59f1dad78ba34c9e707571c2c400de4cfa38cc64a17df6c3
7
- data.tar.gz: ab014e25402995142c30c102ed900801ed4d49d5afe20165624e553a0e25d5651daf12ae7a9df58493f70ada25c5c4b69ea94c307a99f963b923727eb5ef689d
6
+ metadata.gz: 95a486e9d4af7765cf41667b0bb43fada6d20eb9e698fb72fa26b8e35b5f2302cd6d61912dfe1e01cebd8541035d792de079d26ba8c14f9fbd3f515c33f735d7
7
+ data.tar.gz: fdc545f109e1cfcb29145a01ac6fdadaae6523aad64390ff77263db19130e59bf94428e7dab13c51763c3f2b16d2a2070636ec8f94f49875465c0f4a3a4fa4a2
@@ -23,7 +23,7 @@ module ActiveRemote
23
23
  end
24
24
  end
25
25
 
26
- # Raised by ActiveRemove::Base.find when remote record is not found when
26
+ # Raised by ActiveRemote::Base.find when remote record is not found when
27
27
  # searching with the given arguments.
28
28
  class RemoteRecordNotFound < ActiveRemoteError
29
29
  attr_accessor :remote_record_class
@@ -47,4 +47,35 @@ module ActiveRemote
47
47
 
48
48
  class UnknownAttributeError < ActiveRemoteError
49
49
  end
50
+
51
+ # Errors from Protobuf
52
+ class BadRequestDataError < ActiveRemoteError
53
+ end
54
+
55
+ class BadRequestProtoError < ActiveRemoteError
56
+ end
57
+
58
+ class ServiceNotFoundError < ActiveRemoteError
59
+ end
60
+
61
+ class MethodNotFoundError < ActiveRemoteError
62
+ end
63
+
64
+ class RpcError < ActiveRemoteError
65
+ end
66
+
67
+ class RpcFailedError < ActiveRemoteError
68
+ end
69
+
70
+ class InvalidRequestProtoError < ActiveRemoteError
71
+ end
72
+
73
+ class BadResponseProtoError < ActiveRemoteError
74
+ end
75
+
76
+ class UnknownHostError < ActiveRemoteError
77
+ end
78
+
79
+ class IOError < ActiveRemoteError
80
+ end
50
81
  end
@@ -22,7 +22,8 @@ module ActiveRemote
22
22
  service_class.client.__send__(rpc_method, @last_request) do |c|
23
23
  # In the event of service failure, raise the error.
24
24
  c.on_failure do |error|
25
- raise ActiveRemoteError, error.message
25
+ protobuf_error = protobuf_error_class(error)
26
+ raise protobuf_error, error.message
26
27
  end
27
28
 
28
29
  # In the event of service success, assign the response.
@@ -36,6 +37,33 @@ module ActiveRemote
36
37
 
37
38
  private
38
39
 
40
+ def protobuf_error_class(error)
41
+ case error.error_type
42
+ when ::Protobuf::Socketrpc::ErrorReason::BAD_REQUEST_DATA
43
+ ::ActiveRemote::BadRequestDataError
44
+ when ::Protobuf::Socketrpc::ErrorReason::BAD_REQUEST_PROTO
45
+ ::ActiveRemote::BadRequestProtoError
46
+ when ::Protobuf::Socketrpc::ErrorReason::SERVICE_NOT_FOUND
47
+ ::ActiveRemote::ServiceNotFoundError
48
+ when ::Protobuf::Socketrpc::ErrorReason::METHOD_NOT_FOUND
49
+ ::ActiveRemote::MethodNotFoundError
50
+ when ::Protobuf::Socketrpc::ErrorReason::RPC_ERROR
51
+ ::ActiveRemote::RpcError
52
+ when ::Protobuf::Socketrpc::ErrorReason::RPC_FAILED_ERROR
53
+ ::ActiveRemote::RpcFailedError
54
+ when ::Protobuf::Socketrpc::ErrorReason::INVALID_REQUEST_PROTO
55
+ ::ActiveRemote::InvalidRequestProtoError
56
+ when ::Protobuf::Socketrpc::ErrorReason::BAD_RESPONSE_PROTO
57
+ ::ActiveRemote::BadResponseProtoError
58
+ when ::Protobuf::Socketrpc::ErrorReason::UNKNOWN_HOST
59
+ ::ActiveRemote::UnknownHostError
60
+ when ::Protobuf::Socketrpc::ErrorReason::IO_ERROR
61
+ ::ActiveRemote::IOError
62
+ else
63
+ ActiveRemoteError
64
+ end
65
+ end
66
+
39
67
  # Return a protobuf request object for the given rpc request.
40
68
  #
41
69
  def request(rpc_method, request_args)
@@ -1,3 +1,3 @@
1
1
  module ActiveRemote
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hutchison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -262,8 +262,48 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  version: '0'
263
263
  requirements: []
264
264
  rubyforge_project:
265
- rubygems_version: 2.6.10
265
+ rubygems_version: 2.6.11
266
266
  signing_key:
267
267
  specification_version: 4
268
268
  summary: Active Record for your platform
269
- test_files: []
269
+ test_files:
270
+ - spec/lib/active_remote/association_spec.rb
271
+ - spec/lib/active_remote/attributes_spec.rb
272
+ - spec/lib/active_remote/base_spec.rb
273
+ - spec/lib/active_remote/dirty_spec.rb
274
+ - spec/lib/active_remote/dsl_spec.rb
275
+ - spec/lib/active_remote/integration_spec.rb
276
+ - spec/lib/active_remote/persistence_spec.rb
277
+ - spec/lib/active_remote/primary_key_spec.rb
278
+ - spec/lib/active_remote/query_attribute_spec.rb
279
+ - spec/lib/active_remote/rpc_spec.rb
280
+ - spec/lib/active_remote/scope_keys_spec.rb
281
+ - spec/lib/active_remote/search_spec.rb
282
+ - spec/lib/active_remote/serialization_spec.rb
283
+ - spec/lib/active_remote/serializers/protobuf_spec.rb
284
+ - spec/lib/active_remote/typecasting_spec.rb
285
+ - spec/lib/active_remote/validations_spec.rb
286
+ - spec/spec_helper.rb
287
+ - spec/support/definitions/author.proto
288
+ - spec/support/definitions/category.proto
289
+ - spec/support/definitions/error.proto
290
+ - spec/support/definitions/post.proto
291
+ - spec/support/definitions/serializer.proto
292
+ - spec/support/definitions/tag.proto
293
+ - spec/support/helpers.rb
294
+ - spec/support/models.rb
295
+ - spec/support/models/author.rb
296
+ - spec/support/models/category.rb
297
+ - spec/support/models/default_author.rb
298
+ - spec/support/models/message_with_options.rb
299
+ - spec/support/models/no_attributes.rb
300
+ - spec/support/models/post.rb
301
+ - spec/support/models/tag.rb
302
+ - spec/support/models/typecasted_author.rb
303
+ - spec/support/protobuf.rb
304
+ - spec/support/protobuf/author.pb.rb
305
+ - spec/support/protobuf/category.pb.rb
306
+ - spec/support/protobuf/error.pb.rb
307
+ - spec/support/protobuf/post.pb.rb
308
+ - spec/support/protobuf/serializer.pb.rb
309
+ - spec/support/protobuf/tag.pb.rb