-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from hmlanigan/replace-application-already-ex…
…ists Replace application already exists
- Loading branch information
Showing
8 changed files
with
176 additions
and
126 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package juju | ||
|
||
import ( | ||
"strings" | ||
|
||
jujuerrors "github.com/juju/errors" | ||
) | ||
|
||
func typedError(err error) error { | ||
switch { | ||
case strings.Contains(err.Error(), "not found"): | ||
return jujuerrors.WithType(err, jujuerrors.NotFound) | ||
case strings.Contains(err.Error(), "already exists"): | ||
return jujuerrors.WithType(err, jujuerrors.AlreadyExists) | ||
case strings.Contains(err.Error(), "user not valid"): | ||
return jujuerrors.WithType(err, jujuerrors.UserNotFound) | ||
case strings.Contains(err.Error(), "not valid"): | ||
return jujuerrors.WithType(err, jujuerrors.NotValid) | ||
case strings.Contains(err.Error(), "not implemented"): | ||
return jujuerrors.WithType(err, jujuerrors.NotImplemented) | ||
case strings.Contains(err.Error(), "not yet available"): | ||
return jujuerrors.WithType(err, jujuerrors.NotYetAvailable) | ||
default: | ||
return err | ||
} | ||
} |
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
Oops, something went wrong.