private Promise<ProfileDto> loadProfile() { return getUserProfile() .catchError( (Operation<PromiseError>) arg -> { throw new OperationException("Unable to load user's profile: " + arg.getCause()); }); }
/** Returns an operation which shows an error notification with the given title. */ private Operation<PromiseError> showErrorNotification(String title) { return err -> { notificationManager.notify(title, err.getMessage(), FAIL, EMERGE_MODE); throw new OperationException(err.getMessage()); }; }
private Promise<Map<String, String>> loadPreferences() { return preferencesManager .loadPreferences() .catchError( (Operation<PromiseError>) arg -> { throw new OperationException( messages.unableToLoadPreference() + ": " + arg.getCause()); }); }
@Override protected Promise<Void> initAppContext() { return super.initAppContext() .thenPromise( aVoid -> getFactory() .then( (Function<FactoryDto, Void>) factory -> { ((AppContextImpl) appContext).setFactory(factory); return null; }) .catchError( (Operation<PromiseError>) err -> { throw new OperationException( "Unable to load Factory: " + err.getMessage(), err.getCause()); }) .then( arg -> { if (RUNNING != appContext.getWorkspace().getStatus()) { throw new OperationException( "Can't load Factory. Workspace is not running."); } })); }
protected Promise<Void> initAppContext() { return getWorkspaceToStart() .then( (Function<WorkspaceImpl, Void>) workspace -> { ((AppContextImpl) appContext).setWorkspace(workspace); ((AppContextImpl) appContext).setStartAppActions(getStartUpActions()); return null; }) .catchError( (Operation<PromiseError>) err -> { throw new OperationException("Can not get workspace: " + err.getCause()); }); }
.orElseThrow( () -> new OperationException( "Machine " + machine.getName()
@Override public Promise<Void> init() { return userInitializer .init() .catchError( (Operation<PromiseError>) err -> { // Fail to initialize the current user. // Since we can't get theme ID from the user's preferences // try to inject CSS styles with a default theme at least // in order to be able to use a minimal UI (dialogs) // for displaying an error information to the user. styleInjector.inject(); // Prevent further initialization steps. throw new OperationException(err.getMessage(), err.getCause()); }) .then(initUI()) .thenPromise(aVoid -> initAppContext()) .then(showUI()) .then( arg -> { eventBus.fireEvent(new BasicIDEInitializedEvent()); }); }
throw new OperationException(arg.getMessage()); });