mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: bring back panic(err.msg)
-> panic(err)
(#9022)
This commit is contained in:
@ -10,7 +10,7 @@ module ttf
|
||||
*
|
||||
* Note:
|
||||
*
|
||||
* TODO:
|
||||
* TODO:
|
||||
**********************************************************************/
|
||||
import os
|
||||
import math
|
||||
@ -93,17 +93,17 @@ pub fn (mut bmp BitMap) save_as_ppm(file_name string) {
|
||||
|
||||
bmp.format_texture()
|
||||
npixels := bmp.width * bmp.height
|
||||
mut f_out := os.create(file_name) or { panic(err.msg) }
|
||||
f_out.writeln('P3') or { panic(err.msg) }
|
||||
f_out.writeln('$bmp.width $bmp.height') or { panic(err.msg) }
|
||||
f_out.writeln('255') or { panic(err.msg) }
|
||||
mut f_out := os.create(file_name) or { panic(err) }
|
||||
f_out.writeln('P3') or { panic(err) }
|
||||
f_out.writeln('$bmp.width $bmp.height') or { panic(err) }
|
||||
f_out.writeln('255') or { panic(err) }
|
||||
for i in 0 .. npixels {
|
||||
pos := i * bmp.bp
|
||||
unsafe {
|
||||
c_r := bmp.buf[pos]
|
||||
c_g := bmp.buf[pos + 1]
|
||||
c_b := bmp.buf[pos + 2]
|
||||
f_out.write_str('$c_r $c_g $c_b ') or { panic(err.msg) }
|
||||
f_out.write_str('$c_r $c_g $c_b ') or { panic(err) }
|
||||
}
|
||||
}
|
||||
f_out.close()
|
||||
@ -127,7 +127,7 @@ pub fn (mut bmp BitMap) get_raw_bytes() []byte {
|
||||
}
|
||||
|
||||
pub fn (mut bmp BitMap) save_raw_data(file_name string) {
|
||||
os.write_file_array(file_name, bmp.get_raw_bytes()) or { panic(err.msg) }
|
||||
os.write_file_array(file_name, bmp.get_raw_bytes()) or { panic(err) }
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -13,7 +13,7 @@ import strings
|
||||
* Note:
|
||||
* use `v -d create_data vlib/x/ttf/ttf_test.v` to generate binary data for this test file
|
||||
*
|
||||
* TODO:
|
||||
* TODO:
|
||||
* - manage text directions R to L
|
||||
**********************************************************************/
|
||||
const font_path = 'Qarmic_sans_Abridged.ttf'
|
||||
@ -156,13 +156,13 @@ fn save_raw_data_as_array(buf_bin []byte, file_name string) {
|
||||
for x in buf_bin {
|
||||
buf.write_string('0x${x:02x},')
|
||||
}
|
||||
os.write_file_array(file_name, buf.buf) or { panic(err.msg) }
|
||||
os.write_file_array(file_name, buf.buf) or { panic(err) }
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
mut tf := ttf.TTF_File{}
|
||||
$if create_data ? {
|
||||
tf.buf = os.read_bytes(font_path) or { panic(err.msg) }
|
||||
tf.buf = os.read_bytes(font_path) or { panic(err) }
|
||||
println('TrueTypeFont file [$font_path] len: $tf.buf.len')
|
||||
save_raw_data_as_array(tf.buf, 'test_ttf_Font_arr.bin')
|
||||
} $else {
|
||||
@ -200,7 +200,7 @@ fn test_main() {
|
||||
$if create_data ? {
|
||||
bmp.save_as_ppm('test_ttf.ppm')
|
||||
bmp.save_raw_data('test_ttf.bin')
|
||||
test_buf = os.read_bytes('test_ttf.bin') or { panic(err.msg) }
|
||||
test_buf = os.read_bytes('test_ttf.bin') or { panic(err) }
|
||||
}
|
||||
|
||||
ram_buf := bmp.get_raw_bytes()
|
||||
|
@ -29,5 +29,5 @@ fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err.msg) }
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err.msg) }
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import x.websocket
|
||||
fn main() {
|
||||
mut s := websocket.new_server(9002, '/')
|
||||
s.on_message(on_message)
|
||||
s.listen() or { panic(err.msg) }
|
||||
s.listen() or { panic(err) }
|
||||
}
|
||||
|
||||
fn handle_case(case_nr int) ? {
|
||||
@ -23,5 +23,5 @@ fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err.msg) }
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
||||
|
@ -29,5 +29,5 @@ fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err.msg) }
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ fn on_message(mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
// We just wanna pass text and binary message back to autobahn
|
||||
return
|
||||
}
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err.msg) }
|
||||
ws.write(msg.payload, msg.opcode) or { panic(err) }
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ pub fn (mut ws Client) listen() ? {
|
||||
ws.logger.error('error in message callback sending PONG: $err')
|
||||
ws.send_error_event('error in message callback sending PONG: $err')
|
||||
if ws.panic_on_callback {
|
||||
panic(err.msg)
|
||||
panic(err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ fn start_server(listen_port int) ? {
|
||||
}) ?
|
||||
s.on_message(fn (mut ws websocket.Client, msg &websocket.Message) ? {
|
||||
match msg.opcode {
|
||||
.pong { ws.write_str('pong') or { panic(err.msg) } }
|
||||
else { ws.write(msg.payload, msg.opcode) or { panic(err.msg) } }
|
||||
.pong { ws.write_str('pong') or { panic(err) } }
|
||||
else { ws.write(msg.payload, msg.opcode) or { panic(err) } }
|
||||
}
|
||||
})
|
||||
|
||||
@ -96,7 +96,7 @@ fn ws_test(uri string) ? {
|
||||
}
|
||||
// sleep to give time to recieve response before asserts
|
||||
time.sleep(1500 * time.millisecond)
|
||||
// We expect at least 2 pongs, one sent directly and one indirectly
|
||||
// We expect at least 2 pongs, one sent directly and one indirectly
|
||||
assert test_results.nr_pong_received >= 2
|
||||
assert test_results.nr_messages == 2
|
||||
}
|
||||
|
Reference in New Issue
Block a user