Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing the correct exceptions. #202

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docking-api/src/ModernDocking/api/DockingStateAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal
import ModernDocking.Dockable;
import ModernDocking.exception.DockableNotFoundException;
import ModernDocking.exception.DockableRegistrationFailureException;
import ModernDocking.exception.RootDockingPanelNotFoundException;
import ModernDocking.internal.*;
import ModernDocking.layouts.*;
import ModernDocking.persist.*;
Expand Down Expand Up @@ -59,7 +60,7 @@ public RootDockState getRootState(Window window) {
RootDockingPanelAPI root = DockingComponentUtils.rootForWindow(docking, window);

if (root == null) {
throw new RuntimeException("Root for window does not exist: " + window);
throw new RootDockingPanelNotFoundException(window);
}

return new RootDockState(root);
Expand All @@ -69,7 +70,7 @@ public WindowLayout getWindowLayout(Window window) {
RootDockingPanelAPI root = DockingComponentUtils.rootForWindow(docking, window);

if (root == null) {
throw new RuntimeException("Root for frame does not exist: " + window);
throw new RootDockingPanelNotFoundException(window);
}

WindowLayout maxLayout = maximizeRestoreLayout.get(window);
Expand Down Expand Up @@ -147,7 +148,7 @@ public void restoreWindowLayout(Window window, WindowLayout layout) {
RootDockingPanelAPI root = DockingComponentUtils.rootForWindow(docking, window);

if (root == null) {
throw new RuntimeException("Root for window does not exist: " + window);
throw new RootDockingPanelNotFoundException(window);
}

if (layout.hasSizeAndLocationInformation()) {
Expand Down Expand Up @@ -220,7 +221,7 @@ public void restoreState(Window window, RootDockState state) {
RootDockingPanelAPI root = DockingComponentUtils.rootForWindow(docking, window);

if (root == null) {
throw new RuntimeException("Root for window does not exist: " + window);
throw new RootDockingPanelNotFoundException(window);
}

DockingComponentUtils.undockComponents(docking, root);
Expand Down
7 changes: 4 additions & 3 deletions docking-api/src/ModernDocking/internal/DockingInternal.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal
import ModernDocking.Dockable;
import ModernDocking.api.DockingAPI;
import ModernDocking.api.RootDockingPanelAPI;
import ModernDocking.exception.DockableNotFoundException;
import ModernDocking.exception.DockableRegistrationFailureException;
import ModernDocking.ui.DefaultHeaderUI;
import ModernDocking.ui.DockingHeaderUI;
Expand Down Expand Up @@ -101,20 +102,20 @@ public DockableWrapper getWrapper(Dockable dockable) {
if (dockables.containsKey(dockable.getPersistentID())) {
return dockables.get(dockable.getPersistentID());
}
throw new DockableRegistrationFailureException(dockable.getPersistentID());
throw new DockableNotFoundException(dockable.getPersistentID());
}

/**
* Find a dockable with the given persistent ID
* @param persistentID persistent ID to search for
* @return found dockable
* @throws DockableRegistrationFailureException if the dockable has not been registered
* @throws DockableNotFoundException if the dockable has not been found
*/
public Dockable getDockable(String persistentID) {
if (dockables.containsKey(persistentID)) {
return dockables.get(persistentID).getDockable();
}
throw new DockableRegistrationFailureException(persistentID);
throw new DockableNotFoundException(persistentID);
}

public void fireDockedEventForFrame(Window window) {
Expand Down