fix: exponer cuerpo real de respuesta en error de websms
El error "unmarshal: invalid character '<'" ocultaba qué devolvía LabsMobile. Ahora el error incluye Content-Type y los primeros 200 bytes del cuerpo para diagnóstico. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ab4e3252b1
commit
e5c6dba787
@@ -92,9 +92,10 @@ func SendWebSms(cfg *models.WebSmsConfig, para, mensaje string) (*WebSmsResponse
|
||||
return nil, fmt.Errorf("websms API status %d: %s", resp.StatusCode, string(respBody))
|
||||
}
|
||||
|
||||
ct := resp.Header.Get("Content-Type")
|
||||
var result WebSmsResponse
|
||||
if err := json.Unmarshal(respBody, &result); err != nil {
|
||||
return nil, fmt.Errorf("websms: unmarshal: %w", err)
|
||||
return nil, fmt.Errorf("websms: respuesta no JSON (Content-Type: %s, cuerpo: %.200s)", ct, string(respBody))
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
|
||||
Reference in New Issue
Block a user