Skip to content

The result type

Those of you familiar with Rust will feel right at home with the Result type this library implements. All requests that go out over the network via the Client come back to you in the form of a Result. The result can be one of two things: an Ok or an Err.

Calling unwrap() on an Err will raise an exception.

Calling unwrap_err() on an Ok will raise an exception.

Correct usage

client = wom.Client(user_agent="@jonxslays")

await client.start()

result = await client.players.update_player("jonxslays")

if result.is_ok:
    print(result.unwrap())
else:
    print(result.unwrap_err())

await client.close()

Incorrect usage

client = wom.Client(user_agent="@jonxslays")

await client.start()

result = await client.players.update_player("eeeeeeeeeeeee")

print(result.unwrap()) # <-- Exception raised
# Raises UnwrapError because username should have been 12 characters or less

# .. Remember to close the client!