Skip to content

Commit

Permalink
add PluginException; add "throws PluginException" to Plugin interface (
Browse files Browse the repository at this point in the history
…#21)

* add PluginException; add "throws PluginException" to Plugin interface

* add all Exception ctors to PluginException
  • Loading branch information
eemhu authored Feb 12, 2025
1 parent 4291695 commit c87c706
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/teragrep/akv_01/plugin/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@

public interface Plugin {

public abstract List<SyslogMessage> syslogMessage(ParsedEvent parsedEvent);
public abstract List<SyslogMessage> syslogMessage(ParsedEvent parsedEvent) throws PluginException;
}
64 changes: 64 additions & 0 deletions src/main/java/com/teragrep/akv_01/plugin/PluginException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Key Value Mapping for Microsoft Azure EventHub
* Copyright (C) 2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* Additional permission under GNU Affero General Public License version 3
* section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with other code, such other code is not for that reason alone subject to any
* of the requirements of the GNU Affero GPL version 3 as long as this Program
* is the same Program as licensed from Suomen Kanuuna Oy without any additional
* modifications.
*
* Supplemented terms under GNU Affero General Public License version 3
* section 7
*
* Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
* versions must be marked as "Modified version of" The Program.
*
* Names of the licensors and authors may not be used for publicity purposes.
*
* No rights are granted for use of trade names, trademarks, or service marks
* which are in The Program if any.
*
* Licensee must indemnify licensors and authors for any liability that these
* contractual assumptions impose on licensors and authors.
*
* To the extent this program is licensed as part of the Commercial versions of
* Teragrep, the applicable Commercial License may apply to this file if you as
* a licensee so wish it.
*/
package com.teragrep.akv_01.plugin;

public final class PluginException extends Exception {

public PluginException() {
}

public PluginException(String message) {
super(message);
}

public PluginException(String message, Throwable cause) {
super(message, cause);
}

public PluginException(Throwable cause) {
super(cause);
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/teragrep/akv_01/plugin/PluginStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
public final class PluginStub implements Plugin {

@Override
public List<SyslogMessage> syslogMessage(final ParsedEvent parsedEvent) {
throw new UnsupportedOperationException("Stub object does not implement any methods");
public List<SyslogMessage> syslogMessage(final ParsedEvent parsedEvent) throws PluginException {
throw new PluginException(new UnsupportedOperationException("Stub object does not implement any methods"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void testSuccessfulInitialization() {
PluginFactory pluginFactory = Assertions.assertDoesNotThrow(pi::pluginFactory);
Assertions.assertEquals(PluginStubFactory.class, pluginFactory.getClass());
Assertions
.assertThrows(UnsupportedOperationException.class, () -> pluginFactory.plugin("dummy-config").syslogMessage(new ParsedEventStub()));
.assertThrows(PluginException.class, () -> pluginFactory.plugin("dummy-config").syslogMessage(new ParsedEventStub()));
}

@Test
Expand Down

0 comments on commit c87c706

Please sign in to comment.