Skip to content

Instantly share code, notes, and snippets.

@laser
Last active August 29, 2015 14:00
Show Gist options
  • Save laser/0a150158b53d28bda229 to your computer and use it in GitHub Desktop.
Save laser/0a150158b53d28bda229 to your computer and use it in GitHub Desktop.
Barrister Error Code (Ruby)
#!/usr/bin/env ruby
# Client sends invalid parameters to server
require 'barrister'
trans = Barrister::HttpTransport.new("http://localhost:3000/v1/todos")
client = Barrister::Client.new(trans)
client.TodoManager.deleteTodo(45) # valid (45 is an int)
begin
client.TodoManager.deleteTodo("66") # invalid ("66" is a string, not an int)
rescue Barrister::RpcException => e
puts "err.code=#{e.code}" # -32602 ("Invalid params" - from the JSON-RPC 2.0 spec)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment