Skip to content

Instantly share code, notes, and snippets.

@jnizet
Created December 21, 2019 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnizet/492c0f796e6dc54e48a3ed1772368267 to your computer and use it in GitHub Desktop.
Save jnizet/492c0f796e6dc54e48a3ed1772368267 to your computer and use it in GitHub Desktop.
public Pojo parseJson(String json) {
// parse
return pojo;
// don't catch the exception. If there is an exception, there is a bug, so you shouldn't catch it and ignore it
// that will only cause a cryptic NullPointerException later.
}
public Mono<Pojo> query(long id) {
Integer value = idMapper.getValue(id);
if (value != null) {
return repo.query(value).map(this::parse);
}
return Mono.error(() -> new NotFoundException("No Pojo with ID could be found"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment