Add any type and output errors

This commit is contained in:
Archie Fox
2025-03-14 15:11:17 +03:00
parent debf1eec22
commit e7bb6ba60a
4 changed files with 25 additions and 8 deletions

View File

@@ -2,10 +2,9 @@ package account
import (
"encoding/json"
"password/output"
"strings"
"time"
"github.com/fatih/color"
)
type ByteReader interface {
@@ -46,7 +45,7 @@ func NewVault(db Db) *VaultWithDb {
var vault Vault
err = json.Unmarshal(file, &vault)
if err != nil {
color.Red("Не удалось разобрать файл data.json")
output.PrintError("Не удалось разобрать файл data.json")
return &VaultWithDb{
Vault: Vault{
Accounts: []Account{},
@@ -105,7 +104,7 @@ func (vault *VaultWithDb) save() {
vault.UpdatedAt = time.Now()
data, err := vault.Vault.ToBytes()
if err != nil {
color.Red("Не удалось преобразовать")
output.PrintError("Не удалось преобразовать")
}
vault.db.Write(data)
}