Skip to content

Commit

Permalink
Improve DidKey error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
filip26 committed Feb 6, 2024
1 parent 360e58d commit dd51dd8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/apicatalog/did/key/DidKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public static final DidKey from(final Did did, final MultibaseDecoder bases, fin
throw new IllegalArgumentException("The given DID method [" + did.getMethod() + "] is not 'key'. DID [" + did.toString() + "].");
}

final Multibase base = bases.getBase(did.getMethodSpecificId()).orElseThrow(() -> new IllegalArgumentException("Cannot detect did:key base encoding."));
final Multibase base = bases.getBase(did.getMethodSpecificId()).orElseThrow(() -> new IllegalArgumentException("Unsupported did:key base encoding. DID [" + did.toString() + "]."));

final byte[] decoded = base.decode(did.getMethodSpecificId());

final Multicodec codec = codecs.getCodec(decoded).orElseThrow(() -> new IllegalArgumentException("Cannot detect did:key codec."));
final Multicodec codec = codecs.getCodec(decoded).orElseThrow(() -> new IllegalArgumentException("Unsupported did:key codec. DID [" + did.toString() + "]."));

final byte[] rawKey = codec.decode(decoded);

Expand Down

0 comments on commit dd51dd8

Please sign in to comment.