Skip to content

Instantly share code, notes, and snippets.

@Amokrane
Last active September 7, 2020 10:35
Show Gist options
  • Save Amokrane/d490978016d0cf7ccaa1e6000f2a7e64 to your computer and use it in GitHub Desktop.
Save Amokrane/d490978016d0cf7ccaa1e6000f2a7e64 to your computer and use it in GitHub Desktop.
// When initializing Criteo
try {
// initialization code
} catch (Exception e) {
// all exceptions will be caught (the checked and unchecked)
}
// when accessing Criteo object
@Nullable
private Criteo getCriteoSafely() {
Criteo criteo = null;
try {
criteo = Criteo.getInstance();
} catch (IllegalStateException e) {
}
return criteo;
}
Criteo criteo = getCriteoSafely();
if (criteo != null) {
// do stuff with Criteo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment