mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
improve errors
This commit is contained in:
parent
f3e40caa8f
commit
8381328ea9
3 changed files with 47 additions and 14 deletions
|
@ -2,6 +2,7 @@ package helper
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/speatzle/go-passbolt/api"
|
||||
)
|
||||
|
@ -12,27 +13,44 @@ func CreateFolder(ctx context.Context, c *api.Client, folderParentID, name strin
|
|||
Name: name,
|
||||
FolderParentID: folderParentID,
|
||||
})
|
||||
return f.ID, err
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Creating Folder: %w", err)
|
||||
}
|
||||
return f.ID, nil
|
||||
}
|
||||
|
||||
// GetFolder Gets a Folder
|
||||
func GetFolder(ctx context.Context, c *api.Client, folderID string) (string, string, error) {
|
||||
f, err := c.GetFolder(ctx, folderID)
|
||||
return f.FolderParentID, f.Name, err
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("Getting Folder: %w", err)
|
||||
}
|
||||
return f.FolderParentID, f.Name, nil
|
||||
}
|
||||
|
||||
// UpdateFolder Updates a Folder
|
||||
func UpdateFolder(ctx context.Context, c *api.Client, folderID, name string) error {
|
||||
_, err := c.UpdateFolder(ctx, folderID, api.Folder{Name: name})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Updating Folder: %w", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteFolder Deletes a Folder
|
||||
func DeleteFolder(ctx context.Context, c *api.Client, folderID string) error {
|
||||
return c.DeleteFolder(ctx, folderID)
|
||||
err := c.DeleteFolder(ctx, folderID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Deleting Folder: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MoveFolder Moves a Folder into a Folder
|
||||
func MoveFolder(ctx context.Context, c *api.Client, folderID, folderParentID string) error {
|
||||
return c.MoveFolder(ctx, folderID, folderParentID)
|
||||
err := c.MoveFolder(ctx, folderID, folderParentID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Moving Folder: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue