Report chats that already exist; do not panic.
This commit is contained in:
parent
d2659f9afc
commit
06557c021e
1 changed files with 4 additions and 0 deletions
|
|
@ -33,6 +33,10 @@ func (c *chats) AddChat(ctx context.Context, cmd *cli.Command) error {
|
|||
mdl := models.NewChatModel(ctx, mdb.DB())
|
||||
_, err := mdl.AddChat(id, name)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrUniqueConstraint) {
|
||||
logger.Error("chat exists")
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
fmt.Printf(`added chat "%s" (%d)\n`, name, id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue