I need to know how to explicitly catch a certain error (exception).
Here is my code:
package main
import (
"bufio"
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"log"
"os"
"path"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/secretsmanager"
)
func main() {
svc := secretsmanager.New(session.New())
result, err := svc.CreateSecret(inputCert)
if err != nil {
fmt.Println(err) //this gives the error "ResourceExistsException"
}
fmt.Println(result)
}
The exception I am getting is ResourceExistsException. The whole output is:
ResourceExistsException: The operation failed because the secret test/nse/test.crt already exists.
What I want to do this, I want to explicity get this exception as there can be other exceptions too (other than ResourceExistsException)
How can I do this?