Skip to content

Commit

Permalink
Add LocalizationException
Browse files Browse the repository at this point in the history
  • Loading branch information
freya022 committed May 9, 2024
1 parent 54be7cf commit 19008e5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.api.exceptions;

import net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction;

/**
* Exception indicating that an error occurred while localizing an application command.
*
* <p>They are usually caused by invalid strings,
* or exceptions in a {@link net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction LocalizationFunction}.
*
* @see net.dv8tion.jda.api.interactions.commands.build.CommandData#setLocalizationFunction(LocalizationFunction) CommandData.setLocalizationFunction(LocalizationFunction)
*/
public class LocalizationException extends RuntimeException
{
public LocalizationException(String message, Throwable cause)
{
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.dv8tion.jda.internal.interactions.command.localization;

import net.dv8tion.jda.api.exceptions.LocalizationException;
import net.dv8tion.jda.api.interactions.DiscordLocale;
import net.dv8tion.jda.api.interactions.commands.Command;
import net.dv8tion.jda.api.interactions.commands.build.*;
Expand Down Expand Up @@ -155,7 +156,7 @@ private void trySetTranslation(LocalizationMap localizationMap, String finalComp
}
catch (Exception e)
{
throw new RuntimeException("Unable to set translations from '" + localizationFunction.getClass().getName() + "' with key '" + key + "'", e);
throw new LocalizationException("Unable to set translations from '" + localizationFunction.getClass().getName() + "' with key '" + key + "'", e);
}
}
}
Expand Down

0 comments on commit 19008e5

Please sign in to comment.