Skip to content

Commit 1c13adf

Browse files
committed
additional checks in PLCOperation
1 parent f54e923 commit 1c13adf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/didkit/plc_operation.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ class FormatError < StandardError
1616

1717
def initialize(json)
1818
@json = json
19+
raise FormatError, "Expected argument to be a Hash, got a #{json.class}" unless @json.is_a?(Hash)
20+
1921
@seq = json['seq']
2022
@did = json['did']
2123
raise FormatError, "Missing DID: #{json}" if @did.nil?
22-
raise FormatError, "Invalid DID: #{@did}" unless @did.is_a?(String) && @did.start_with?('did:')
24+
raise FormatError, "Invalid DID: #{@did.inspect}" unless @did.is_a?(String) && @did.start_with?('did:')
2325

2426
@cid = json['cid']
2527
raise FormatError, "Missing CID: #{json}" if @cid.nil?

0 commit comments

Comments
 (0)