go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/blogctl/pkg/aws/s3/errors.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package s3
     9  
    10  import (
    11  	"github.com/aws/aws-sdk-go/aws/awserr"
    12  	"github.com/aws/aws-sdk-go/service/s3"
    13  )
    14  
    15  // IsNotFound returns if an error is a not found error.
    16  func IsNotFound(err error) bool {
    17  	if err != nil {
    18  		if aerr, ok := err.(awserr.Error); ok {
    19  			switch aerr.Code() {
    20  			case s3.ErrCodeNoSuchBucket:
    21  				return true
    22  			case s3.ErrCodeNoSuchKey:
    23  				return true
    24  			}
    25  		}
    26  	}
    27  	return false
    28  }