From a69e6febbc98632559dc1e9d4d4531ac1cd0fb85 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 23 Jun 2019 10:41:42 +0200 Subject: [PATCH] use new exit() everywhere --- examples/news_fetcher.v | 3 ++- gg/gg.v | 10 ++++++---- gl/1shader.v | 9 ++++++--- gl/gl.v | 3 ++- stbi/stbi.v | 3 ++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/news_fetcher.v b/examples/news_fetcher.v index 1ef9596241..1a9a7699e8 100644 --- a/examples/news_fetcher.v +++ b/examples/news_fetcher.v @@ -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') } diff --git a/gg/gg.v b/gg/gg.v index a04fa800e9..192266860a 100644 --- a/gg/gg.v +++ b/gg/gg.v @@ -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() } } */ diff --git a/gl/1shader.v b/gl/1shader.v index ccf5f65b2d..03b1bb3648 100644 --- a/gl/1shader.v +++ b/gl/1shader.v @@ -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, diff --git a/gl/gl.v b/gl/gl.v index a3bcdb3014..8fe6674e4e 100644 --- a/gl/gl.v +++ b/gl/gl.v @@ -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) } } diff --git a/stbi/stbi.v b/stbi/stbi.v index 78a5a1078a..f81ee04b69 100644 --- a/stbi/stbi.v +++ b/stbi/stbi.v @@ -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 }