1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

examples: fix unset reader notice for the smtp/mail example (#17998)

This commit is contained in:
Thomas Peißl 2023-05-02 21:54:57 +02:00 committed by GitHub
parent d3dbd7b743
commit 353de60158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -31,6 +31,6 @@ fn main() {
body_type: .html body_type: .html
body: body body: body
} }
mut client := smtp.new_client(client_cfg) or { panic('Error configuring smtp') } mut client := smtp.new_client(client_cfg) or { panic('Error with configuring smtp: ${err}') }
client.send(send_cfg) or { panic('Error resolving email address') } client.send(send_cfg) or { panic('Error resolving email address: ${err}') }
} }

View File

@ -33,7 +33,7 @@ pub struct Client {
mut: mut:
conn net.TcpConn conn net.TcpConn
ssl_conn &ssl.SSLConn = unsafe { nil } ssl_conn &ssl.SSLConn = unsafe { nil }
reader io.BufferedReader reader ?&io.BufferedReader
pub: pub:
server string server string
port int = 25 port int = 25
@ -139,7 +139,7 @@ fn (mut c Client) connect_ssl() ! {
fn (mut c Client) expect_reply(expected ReplyCode) ! { fn (mut c Client) expect_reply(expected ReplyCode) ! {
mut str := '' mut str := ''
for { for {
str = c.reader.read_line()! str = c.reader or { return error('the Client.reader field is not set') }.read_line()!
if str.len < 4 { if str.len < 4 {
return error('Invalid SMTP response: ${str}') return error('Invalid SMTP response: ${str}')
} }