mirror of
https://github.com/langgenius/dify-cloud-kit.git
synced 2026-07-19 13:35:54 -04:00
4ffc7bdc65
* add oss factory and s3 implement * update tests * add azure blob implement * add aliyun oss implement * add tencent cos implement * enhance s3 create bucket logic, only create if not found * add gcs implement * add huawei obs implement * add readme * add readme * update readme * update readme * add static errors * add vendor info to tests
40 lines
844 B
Go
40 lines
844 B
Go
package oss
|
|
|
|
import "fmt"
|
|
|
|
var (
|
|
ErrProviderNotFound = NewCloudKitError("provider not found", "")
|
|
ErrArgumentInvalid = NewCloudKitError("argument invalid", "")
|
|
ErrProviderInit = NewCloudKitError("provider init error", "")
|
|
)
|
|
|
|
type CloudKitError struct {
|
|
Reason string
|
|
Detail string
|
|
Err error
|
|
}
|
|
|
|
func NewCloudKitError(reason string, detail string) *CloudKitError {
|
|
return &CloudKitError{
|
|
Reason: reason,
|
|
Detail: detail,
|
|
}
|
|
}
|
|
|
|
func (c *CloudKitError) Error() string {
|
|
if c.Detail != "" {
|
|
return fmt.Sprintf("reason: %s; detail: %s; error: %v", c.Reason, c.Detail, c.Err)
|
|
}
|
|
return fmt.Sprintf("reason: %s; error: %v", c.Reason, c.Err)
|
|
}
|
|
|
|
func (c *CloudKitError) WithDetail(detail string) *CloudKitError {
|
|
c.Detail = detail
|
|
return c
|
|
}
|
|
|
|
func (c *CloudKitError) WithError(err error) *CloudKitError {
|
|
c.Err = err
|
|
return c
|
|
}
|