feat: return most backend API errors to frontend (#1836)

* feat: return most backend API errros to frontend

Signed-off-by: yehong <239859435@qq.com>

* refactor: reduce int type change

Signed-off-by: yehong <239859435@qq.com>

* feat: return err backend in token.go

Signed-off-by: yehong <239859435@qq.com>

---------

Signed-off-by: yehong <239859435@qq.com>
This commit is contained in:
yehong
2023-05-30 15:49:39 +08:00
committed by GitHub
parent 34151c0095
commit 02e692a300
105 changed files with 3788 additions and 1734 deletions

View File

@ -14,8 +14,12 @@
package object
func (application *Application) GetProviderByCategory(category string) *Provider {
providers := GetProviders(application.Organization)
func (application *Application) GetProviderByCategory(category string) (*Provider, error) {
providers, err := GetProviders(application.Organization)
if err != nil {
return nil, err
}
m := map[string]*Provider{}
for _, provider := range providers {
if provider.Category != category {
@ -27,22 +31,22 @@ func (application *Application) GetProviderByCategory(category string) *Provider
for _, providerItem := range application.Providers {
if provider, ok := m[providerItem.Name]; ok {
return provider
return provider, nil
}
}
return nil
return nil, nil
}
func (application *Application) GetEmailProvider() *Provider {
func (application *Application) GetEmailProvider() (*Provider, error) {
return application.GetProviderByCategory("Email")
}
func (application *Application) GetSmsProvider() *Provider {
func (application *Application) GetSmsProvider() (*Provider, error) {
return application.GetProviderByCategory("SMS")
}
func (application *Application) GetStorageProvider() *Provider {
func (application *Application) GetStorageProvider() (*Provider, error) {
return application.GetProviderByCategory("Storage")
}