Skip to content

Commit

Permalink
feat(framework): Adjust exceptions to new error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStegii committed Feb 26, 2024
1 parent 858357d commit c456802
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 3 additions & 3 deletions framework/src/main/java/org/fulib/fx/FulibFxApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.fulib.fx.dagger.DaggerFrameworkComponent;
import org.fulib.fx.dagger.FrameworkComponent;
import org.fulib.fx.util.ControllerUtil;
import org.fulib.fx.util.FrameworkUtil;
import org.fulib.fx.util.ReflectionUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.MustBeInvokedByOverriders;
Expand All @@ -29,6 +28,7 @@
import java.util.ResourceBundle;
import java.util.function.Function;
import java.util.logging.Logger;
import static org.fulib.fx.util.FrameworkUtil.error;

public abstract class FulibFxApp extends Application {

Expand Down Expand Up @@ -127,7 +127,7 @@ public static void setResourcesPath(@NotNull Path path) {
*/
public @NotNull <T extends Parent> T initAndRender(@NotNull T component, Map<String, Object> params, DisposableContainer onDestroy) {
if (!ControllerUtil.isComponent(component))
throw new IllegalArgumentException(FrameworkUtil.error(1000).formatted(component.getClass().getName()));
throw new IllegalArgumentException(error(1000).formatted(component.getClass().getName()));

Disposable disposable = this.component.controllerManager().init(component, params, false);
if (onDestroy != null) {
Expand Down Expand Up @@ -202,7 +202,7 @@ public void stop() {
*/
public @NotNull Parent show(@NotNull Object controller, @NotNull Map<String, Object> params) {
if (!ControllerUtil.isController(controller))
throw new IllegalArgumentException("Class '%s' is not a controller.".formatted(controller.getClass().getName()));
throw new IllegalArgumentException(error(1001).formatted(controller.getClass().getName()));
cleanup();
Parent renderedParent = this.frameworkComponent().controllerManager().initAndRender(controller, params);
this.currentMainController = controller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,6 @@ public void setDefaultResourceBundle(ResourceBundle resourceBundle) {
* @return The title of the controller
*/
public Optional<String> getTitle(@NotNull Object instance) {
if (!ControllerUtil.isController(instance)) {
throw new IllegalArgumentException("Class '%s' is not a controller or component.".formatted(instance.getClass().getName()));
}
if (!instance.getClass().isAnnotationPresent(Title.class))
return Optional.empty();

Expand Down

0 comments on commit c456802

Please sign in to comment.