Result

Result<T, ERR> is a generic class to return a result of class T or an error of type ERR. It is inspired by the Rust Result type.

This class is used for returning and propagating errors without throwing exceptions. Thus, errors are handled in a functional way and considered as a part of the result.

All methods return results from the API calls using this class.

---
title: Result
---

classDiagram
  class Result~T,ERR~ {
    +Result~T~ ok(T)$
    +Result~ERR~ err(ERR)$
    +T unwrap()
    +ERR unwrapErr()
    +boolean isOk()
    +boolean isErr()
  }

For example:

var url = "https://entrepot.recherche.data.gouv.fr/";
var token = "1234abcd-1abc-123a-12a1-1ab1abc12a1a";
var collection = "tp";
var config = new DataverseConfiguration(url, collection, token);

var client = new DataverseClient(config);

var result = client.checkConfiguration();

if (result.isErr()) {
    System.out.println("Error while checking configuration: " + result.unwrapErr());
} else {
    System.out.println("Configuration check: " + result.unwrap());
}