github.com/abolfazlbeh/zhycan@v0.0.0-20230819144214-24cf38237387/internal/db/error.go (about)

     1  package db
     2  
     3  import "fmt"
     4  
     5  // NotImplementedErr Error
     6  type NotImplementedErr struct {
     7  }
     8  
     9  // Error method - satisfying error interface
    10  func (err *NotImplementedErr) Error() string {
    11  	return fmt.Sprintf("Not Implemented Yet")
    12  }
    13  
    14  // NewNotImplementedErr - return a new instance of NotImplementedErr
    15  func NewNotImplementedErr() error {
    16  	return &NotImplementedErr{}
    17  }
    18  
    19  // CreateSqlWrapperErr Error
    20  type CreateSqlWrapperErr struct {
    21  	Err error
    22  }
    23  
    24  // Error method - satisfying error interface
    25  func (err *CreateSqlWrapperErr) Error() string {
    26  	return fmt.Sprintf("Create a new sql wrapper encounterred an error: %v", err.Err)
    27  }
    28  
    29  // NewCreateSqlWrapperErr - return a new instance of CreateSqlWrapperErr
    30  func NewCreateSqlWrapperErr(err error) error {
    31  	return &CreateSqlWrapperErr{Err: err}
    32  }
    33  
    34  // NotSupportedDbTypeErr Error
    35  type NotSupportedDbTypeErr struct {
    36  	dbType string
    37  }
    38  
    39  // Error method - satisfying error interface
    40  func (err *NotSupportedDbTypeErr) Error() string {
    41  	return fmt.Sprintf("Not Supported Database Dialect: %v", err.dbType)
    42  }
    43  
    44  // NewNotSupportedDbTypeErr - return a new instance of NotSupportedDbTypeErr
    45  func NewNotSupportedDbTypeErr(dbType string) error {
    46  	return &NotSupportedDbTypeErr{dbType: dbType}
    47  }
    48  
    49  // NotExistServiceNameErr Error
    50  type NotExistServiceNameErr struct {
    51  	serviceName string
    52  }
    53  
    54  // Error method - satisfying error interface
    55  func (err *NotExistServiceNameErr) Error() string {
    56  	return fmt.Sprintf("Instance with service name not exist: %v", err.serviceName)
    57  }
    58  
    59  // NewNotExistServiceNameErr - return a new instance of NotExistServiceNameErr
    60  func NewNotExistServiceNameErr(serviceName string) error {
    61  	return &NotExistServiceNameErr{serviceName: serviceName}
    62  }
    63  
    64  // MigrateErr Error
    65  type MigrateErr struct {
    66  	Err error
    67  }
    68  
    69  // Error method - satisfying error interface
    70  func (err *MigrateErr) Error() string {
    71  	return fmt.Sprintf("Migrating tables got error: %v", err.Err)
    72  }
    73  
    74  // NewMigrateErr - return a new instance of MigrateErr
    75  func NewMigrateErr(err error) error {
    76  	return &MigrateErr{Err: err}
    77  }
    78  
    79  // CreateMongoWrapperErr Error
    80  type CreateMongoWrapperErr struct {
    81  	Err error
    82  }
    83  
    84  // Error method - satisfying error interface
    85  func (err *CreateMongoWrapperErr) Error() string {
    86  	return fmt.Sprintf("Create a new mongo wrapper encounterred an error: %v", err.Err)
    87  }
    88  
    89  // NewCreateMongoWrapperErr - return a new instance of CreateMongoWrapperErr
    90  func NewCreateMongoWrapperErr(err error) error {
    91  	return &CreateMongoWrapperErr{Err: err}
    92  }