Skip to content

Commit

Permalink
Merge pull request #36 from vorburger/cid-naming
Browse files Browse the repository at this point in the history
Use uppercase 'CID' in all exception messages
  • Loading branch information
ianopolous authored Jan 4, 2025
2 parents ff4cd66 + d842c6b commit 481a75c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/io/ipfs/cid/Cid.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public byte[] toBytes() {
return toBytesV0();
else if (version == 1)
return toBytesV1();
throw new IllegalStateException("Unknown cid version: " + version);
throw new IllegalStateException("Unknown CID version: " + version);
}

@Override
Expand All @@ -122,7 +122,7 @@ public String toString() {
} else if (version == 1) {
return Multibase.encode(Multibase.Base.Base32, toBytesV1());
}
throw new IllegalStateException("Unknown Cid version: " + version);
throw new IllegalStateException("Unknown CID version: " + version);
}

@Override
Expand Down Expand Up @@ -170,7 +170,7 @@ public static Cid buildCidV1(Codec c, Multihash.Type type, byte[] hash) {

public static Cid decode(String v) {
if (v.length() < 2)
throw new IllegalStateException("Cid too short!");
throw new IllegalStateException("CID too short: " + v);

// support legacy format
if (v.length() == 46 && v.startsWith("Qm"))
Expand All @@ -188,7 +188,7 @@ public static Cid cast(byte[] data) {
try {
long version = readVarint(in);
if (version != 0 && version != 1)
throw new CidEncodingException("Invalid Cid version number: " + version);
throw new CidEncodingException("Invalid CID version number: " + version);

long codec = readVarint(in);
Multihash hash = Multihash.deserialize(in);
Expand All @@ -197,7 +197,7 @@ public static Cid cast(byte[] data) {
} catch (CidEncodingException cee) {
throw cee;
} catch (Exception e) {
throw new CidEncodingException("Invalid cid bytes: " + bytesToHex(data), e);
throw new CidEncodingException("Invalid CID bytes: " + bytesToHex(data), e);
}
}

Expand Down

0 comments on commit 481a75c

Please sign in to comment.