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

use new exit() everywhere

This commit is contained in:
Alexander Medvednikov 2019-06-23 10:41:42 +02:00
parent b2851daffc
commit a69e6febbc
5 changed files with 18 additions and 10 deletions

View File

@ -33,7 +33,8 @@ fn (f mut Fetcher) fetch() {
f.mu.unlock()
resp := http.get('https://hacker-news.firebaseio.com/v0/item/${id}.json')
story := json.decode(Story, resp) or {
exit('failed to decode a story')
println('failed to decode a story')
exit(1)
}
println('#$f.cursor) $story.title')
}

10
gg/gg.v
View File

@ -273,7 +273,8 @@ fn ft_load_char(_face Face, code long) Character {
# FT_Face face = *((FT_Face*)_face.cobj);
# if (FT_Load_Char(face, code, FT_LOAD_RENDER))
{
os.exit('ERROR::FREETYTPE: Failed to load Glyph')
println('freetype: Failed to load Glyph')
exit(1)
}
// Generate texture
# GLuint texture;
@ -345,14 +346,15 @@ fn new_context_text(cfg Cfg, scale int) *GG {
}
if !os.file_exists(font_path) {
println('failed to load RobotoMono-Regular.ttf')
exit('')
exit1()
}
# FT_Face face;
# if (FT_New_Face(ft, font_path.str, 0, &face))
// # if (FT_New_Face(ft, "/Library/Fonts/Courier New.ttf", 0, &face))
// # if (FT_New_Face(ft, "/System/Library/Fonts/Apple Color Emoji.ttc", 0, &face))
{
exit('ERROR::FREETYPE: Failed to load font')
println('freetyp: Failed to load font')
exit(1)
}
// Set size to load glyphs as
# FT_Set_Pixel_Sizes(face, 0, font_size) ;
@ -466,7 +468,7 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) {
firstc := utext.at(0)
println('drawtext "$utext.s" len=$utext.s.len ulen=$utext.len x=$_x firstc=$firstc')
if firstc != ' ' {
exit('')
exit1()
}
}
*/

View File

@ -125,7 +125,8 @@ pub fn new_shader(name string) Shader {
log := gl.shader_info_log(vertex_shader)
println('shader $vertex_shader compilation failed')
println('shader source = $vertex_src')
os.exit('shader')
println('shader failed to compile')
exit(1)
}
// fragment shader
// fragment_src := os.read_file(fragment_path.trim_space())
@ -134,7 +135,8 @@ pub fn new_shader(name string) Shader {
gl.compile_shader(fragment_shader)
if gl.shader_compile_status(fragment_shader) == 0 {
println('fragment $fragment_shader shader compilation failed')
os.exit('shader')
println('shader failed to compile')
exit(1)
}
// link shaders
shader_program := gl.create_program()
@ -147,7 +149,8 @@ pub fn new_shader(name string) Shader {
println('shader compilation failed')
println('vertex source = $vertex_src')
println('fragment source = $fragment_src')
os.exit('shader')
println('shader failed to compile')
exit(1)
}
shader := Shader {
program_id: shader_program,

View File

@ -18,7 +18,8 @@ import const (
fn init_glad() {
ok := C.gladLoadGL()
if !ok {
os.exit('Failed to initialize glad OpenGL context')
println('Failed to initialize glad OpenGL context')
exit(1)
}
}

View File

@ -41,7 +41,8 @@ fn load(path string) Image {
res.data = C.stbi_load(path.str, &res.width, &res.height, &res.nr_channels, 0)
}
if isnil(res.data) {
exit('stbi cant load')
println('stbi cant load')
exit(1)
}
return res
}