Skip to content

Commit

Permalink
switch to default model when receiving ResourceNotFoundException (#3941)
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-ShaoHua authored Oct 26, 2023
1 parent 347cfdc commit 925cb69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import software.amazon.awssdk.services.codewhispererruntime.model.GenerateComple
import software.amazon.awssdk.services.codewhispererruntime.model.GenerateCompletionsResponse
import software.amazon.awssdk.services.codewhispererruntime.model.ProgrammingLanguage
import software.amazon.awssdk.services.codewhispererruntime.model.RecommendationsWithReferencesPreference
import software.amazon.awssdk.services.codewhispererruntime.model.ResourceNotFoundException
import software.amazon.awssdk.services.codewhispererruntime.model.SupplementalContext
import software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException
import software.aws.toolkits.core.utils.debug
Expand Down Expand Up @@ -258,8 +259,8 @@ class CodeWhispererService {
val displayMessage: String

if (
CodeWhispererConstants.Customization.customizationNotFoundExceptionPredicate(e) ||
CodeWhispererConstants.Customization.invalidCustomizationExceptionPredicate(e)
CodeWhispererConstants.Customization.invalidCustomizationExceptionPredicate(e) ||
e is ResourceNotFoundException
) {
(e as CodeWhispererRuntimeException)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ object CodeWhispererConstants {
object Customization {
private const val noAccessToCustomizationMessage = "Your account is not authorized to use CodeWhisperer Enterprise."
private const val invalidCustomizationMessage = "You are not authorized to access"
private const val customizationNotFoundMessage = "not found"

val noAccessToCustomizationExceptionPredicate: (e: Exception) -> Boolean = { e ->
if (e !is CodeWhispererRuntimeException) {
Expand All @@ -110,14 +109,6 @@ object CodeWhispererConstants {
e is AccessDeniedException && (e.message?.contains(invalidCustomizationMessage, ignoreCase = true) ?: false)
}
}

val customizationNotFoundExceptionPredicate: (e: Exception) -> Boolean = { e ->
if (e !is CodeWhispererRuntimeException) {
false
} else {
e is AccessDeniedException && (e.message?.contains(customizationNotFoundMessage, ignoreCase = true) ?: false)
}
}
}
object CrossFile {
const val CHUNK_SIZE = 60
Expand Down

0 comments on commit 925cb69

Please sign in to comment.