Error codes
This page lists specific error codes you might encounter when defining or working with the Truvity SDK, along with guidance on how to resolve them.
T001 - Missing VcContext
annotation on UDT definition
When you define a user-defined type (UDT), you must add a VcContext
annotation to the type. Without this annotation, the Truvity SDK can't recognize the type as a UDT.
The following examples show how to add the annotation in different languages.
- TypeScript
- Java
@VcContext({ name: 'SimpleCredential', namespace: 'https://example.com/credentials' })
class SimpleCredential {
@VcClaim
name!: string;
@VcClaim
age!: number;
}
@VcContext(name = "SimpleCredential", namespace = "https://example.com/credentials")
public static class SimpleCredential {
private Optional<String> name;
private Optional<Integer> age;
}
Further reading: SDK quick start guide
T002 - Unexpected type in serialization or deserialization
This error occurs when the type of a value during serialization or deserialization doesn’t match the UDT definition.
When you serialize data, the error happens if a value doesn’t match the declared type in the UDT claim. To fix it, either update the source values to match the UDT definition or update the UDT definition to match the source values.
When you deserialize data, the error happens if you change a UDT definition in a backward-incompatible way and try to deserialize existing data.
For example, if you originally define a claim as an integer
and later change it to a string
, deserialization fails for existing data.
To fix this, either revert the backward-incompatible change or update the UDT definition to stay compatible with the stored data.
Further reading: Define credential schema using UDT
T003 - Unsupported data type in a user-defined type (UDT)
This error occurs when a field in your user-defined type (UDT) uses a data type that the SDK does not accept.
Further reading: Supported data types
T004 - Incompatible resource credential type
This error occurs when you attempt to retrieve or operate with a credential using a VcDecorator
bound to a different UDT. Each UDT requires its own VcDecorator
so that the SDK applies the correct schema.
The examples below show how to create and use a VcDecorator
for two UDTs: PersonalDetails
and Address
.
- TypeScript
- Java
@VcContext({ name: 'PersonalDetails', namespace: 'https://example.com/credentials' })
class PersonalDetails {
@VcClaim
name!: string;
@VcClaim
age!: number;
}
@VcContext({ name: 'Address', namespace: 'https://example.com/credentials' })
class Address {
@VcClaim
street!: string;
city!: string;
}
// This VcDecorator instance should be used for working with the
// PersonalDetails UDT
const peronalDetailsDecorator = client.createVcDecorator(PersonalDetails);
const personalDetailsDraft = await personalDetailsDecorator.create({
claims: {
name: "Alice",
age: 30
}
});
// This VcDecorator instance should be used for working with the
// Address UDT
const addressDecorator = client.createVcDecorator(Address);
const addressDraft = await addressDecorator.create({
claims: {
street: "Kinkerstraat",
city: "Amsterdam"
}
});
@VcContext(name = "PersonalDetails", namespace = "https://example.com/credentials")
public static class PersonalDetails {
private String name;
private Integer age;
}
@VcContext(name = "Address", namespace = "https://example.com/credentials")
public static class Address {
private String street;
private String city;
}
// This VcDecorator instance should be used for working with the
// PersonalDetails UDT
VcDecorator<PersonalDetails> personalDetailsDecorator = client.vcDecorator(PersonalDetails.class);
PersonalDetails personalDetailsData = new PersonalDetails();
personalDetailsData.name = "Alice";
personalDetailsData.age = 30;
var draft = personalDetailsDecorator.create(personalDetailsData);
// This VcDecorator instance should be used for working with the
// Address UDT
VcDecorator<Address> addressDecorator = client.vcDecorator(Address.class);
Address addressData = new Address();
addressData.street = "Kinkerstraat";
addressData.city = "Amsterdam";
var draft = addressDecorator.create(addressData);