-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] W-16354625: Added required exceptions for each operation (#18)
* W-16354625: Added required exceptions for each operation * W-16354625: Added exception handling for tools operations * W-16354625: Fixed reformatting * W-16354625: Bug fixes and added supported errors per operation
- Loading branch information
Showing
20 changed files
with
726 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/main/java/org/mule/extension/mulechain/internal/error/MuleChainErrorType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.error; | ||
|
||
import org.mule.runtime.extension.api.error.ErrorTypeDefinition; | ||
|
||
public enum MuleChainErrorType implements ErrorTypeDefinition<MuleChainErrorType> { | ||
|
||
INVALID_AUTHENTICATION, IO_EXCEPTION, TIME_OUT, RATE_LIMIT_OR_QUOTA_EXCEEDED; | ||
AI_SERVICES_FAILURE, IMAGE_ANALYSIS_FAILURE, IMAGE_GENERATION_FAILURE, IMAGE_PROCESSING_FAILURE, FILE_HANDLING_FAILURE, RAG_FAILURE, EMBEDDING_OPERATIONS_FAILURE, TOOLS_OPERATION_FAILURE, VALIDATION_FAILURE | ||
} |
23 changes: 23 additions & 0 deletions
23
...java/org/mule/extension/mulechain/internal/error/provider/AiServiceErrorTypeProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.error.provider; | ||
|
||
import org.mule.runtime.extension.api.annotation.error.ErrorTypeProvider; | ||
import org.mule.runtime.extension.api.error.ErrorTypeDefinition; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import static java.util.Collections.unmodifiableSet; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.AI_SERVICES_FAILURE; | ||
|
||
public class AiServiceErrorTypeProvider implements ErrorTypeProvider { | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Override | ||
public Set<ErrorTypeDefinition> getErrorTypes() { | ||
return unmodifiableSet(new HashSet<>(Collections.singletonList(AI_SERVICES_FAILURE))); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...java/org/mule/extension/mulechain/internal/error/provider/EmbeddingErrorTypeProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.error.provider; | ||
|
||
import org.mule.runtime.extension.api.annotation.error.ErrorTypeProvider; | ||
import org.mule.runtime.extension.api.error.ErrorTypeDefinition; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.unmodifiableSet; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.AI_SERVICES_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.EMBEDDING_OPERATIONS_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.FILE_HANDLING_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.RAG_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.TOOLS_OPERATION_FAILURE; | ||
|
||
public class EmbeddingErrorTypeProvider implements ErrorTypeProvider { | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Override | ||
public Set<ErrorTypeDefinition> getErrorTypes() { | ||
return unmodifiableSet(new HashSet<>(asList(EMBEDDING_OPERATIONS_FAILURE, AI_SERVICES_FAILURE, RAG_FAILURE, | ||
FILE_HANDLING_FAILURE, TOOLS_OPERATION_FAILURE))); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ain/java/org/mule/extension/mulechain/internal/error/provider/ImageErrorTypeProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.error.provider; | ||
|
||
import org.mule.runtime.extension.api.annotation.error.ErrorTypeProvider; | ||
import org.mule.runtime.extension.api.error.ErrorTypeDefinition; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.unmodifiableSet; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.FILE_HANDLING_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.IMAGE_ANALYSIS_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.IMAGE_GENERATION_FAILURE; | ||
import static org.mule.extension.mulechain.internal.error.MuleChainErrorType.IMAGE_PROCESSING_FAILURE; | ||
|
||
public class ImageErrorTypeProvider implements ErrorTypeProvider { | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Override | ||
public Set<ErrorTypeDefinition> getErrorTypes() { | ||
return unmodifiableSet(new HashSet<>(asList(IMAGE_ANALYSIS_FAILURE, IMAGE_GENERATION_FAILURE, IMAGE_PROCESSING_FAILURE, | ||
FILE_HANDLING_FAILURE))); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/mule/extension/mulechain/internal/exception/ChatException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class ChatException extends ModuleException { | ||
|
||
public ChatException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.AI_SERVICES_FAILURE, exception); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/org/mule/extension/mulechain/internal/exception/FileHandlingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class FileHandlingException extends ModuleException { | ||
|
||
public FileHandlingException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.FILE_HANDLING_FAILURE, exception); | ||
} | ||
|
||
public FileHandlingException(String message) { | ||
super(message, MuleChainErrorType.FILE_HANDLING_FAILURE); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/mule/extension/mulechain/internal/exception/PromptTemplateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class PromptTemplateException extends ModuleException { | ||
|
||
public PromptTemplateException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.AI_SERVICES_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/java/org/mule/extension/mulechain/internal/exception/SentimentAnalyzerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class SentimentAnalyzerException extends ModuleException { | ||
|
||
public SentimentAnalyzerException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.AI_SERVICES_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ava/org/mule/extension/mulechain/internal/exception/config/ConfigValidationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.config; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class ConfigValidationException extends ModuleException { | ||
|
||
public ConfigValidationException(String message) { | ||
super(message, MuleChainErrorType.VALIDATION_FAILURE); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...e/extension/mulechain/internal/exception/embedding/EmbeddingStoreOperationsException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.embedding; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class EmbeddingStoreOperationsException extends ModuleException { | ||
|
||
public EmbeddingStoreOperationsException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.EMBEDDING_OPERATIONS_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/mule/extension/mulechain/internal/exception/embedding/RagException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.embedding; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class RagException extends ModuleException { | ||
|
||
public RagException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.RAG_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...in/java/org/mule/extension/mulechain/internal/exception/image/ImageAnalyzerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.image; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class ImageAnalyzerException extends ModuleException { | ||
|
||
public ImageAnalyzerException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.IMAGE_ANALYSIS_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../java/org/mule/extension/mulechain/internal/exception/image/ImageGenerationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.image; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class ImageGenerationException extends ModuleException { | ||
|
||
public ImageGenerationException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.IMAGE_GENERATION_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../java/org/mule/extension/mulechain/internal/exception/image/ImageProcessingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.image; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class ImageProcessingException extends ModuleException { | ||
|
||
public ImageProcessingException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.IMAGE_PROCESSING_FAILURE, exception); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...n/java/org/mule/extension/mulechain/internal/exception/tools/ToolsOperationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* (c) 2003-2024 MuleSoft, Inc. The software in this package is published under the terms of the Commercial Free Software license V.1 a copy of which has been included with this distribution in the LICENSE.md file. | ||
*/ | ||
package org.mule.extension.mulechain.internal.exception.tools; | ||
|
||
import org.mule.extension.mulechain.internal.error.MuleChainErrorType; | ||
import org.mule.runtime.extension.api.exception.ModuleException; | ||
|
||
public class ToolsOperationException extends ModuleException { | ||
|
||
public ToolsOperationException(String message, Exception exception) { | ||
super(message, MuleChainErrorType.TOOLS_OPERATION_FAILURE, exception); | ||
} | ||
} |
Oops, something went wrong.