mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
[messages] improve content errors handling
This commit is contained in:
parent
a6fbdcc1ba
commit
2152e60243
@ -2,6 +2,7 @@ package messages
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/android-sms-gateway/server/internal/sms-gateway/models"
|
||||
@ -74,7 +75,7 @@ func (m *Message) GetTextContent() (*TextMessageContent, error) {
|
||||
|
||||
err := json.Unmarshal([]byte(m.Content), &content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to unmarshal text content: %w", err)
|
||||
}
|
||||
|
||||
return &content, nil
|
||||
@ -101,7 +102,7 @@ func (m *Message) GetDataContent() (*DataMessageContent, error) {
|
||||
|
||||
err := json.Unmarshal([]byte(m.Content), &content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to unmarshal data content: %w", err)
|
||||
}
|
||||
|
||||
return &content, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user