You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm going through the tutorial and I've stumbled upon this so I used the proposed replacements, thiserror for the auto Display trait functionality and anyhow in main file for "anyerror" type handling.
e.g shader.rs
use thiserror::Error;#[derive(Error,Debug)]pubenumError{#[error("Failed to load resource {}", name)]ResourceLoad{name:String,#[source]inner: resources::Error,},#[error("Can not determine shader type for resource {}", name)]CanNotDetermineShaderTypeForResource{name:String},#[error("Failed to compile shader {}: {}", name, message)]CompileError{name:String,message:String},#[error("Failed to link program {}: {}", name, message)]LinkError{name:String,message:String},}
and main.rs (Truncated for brevity, showing mainly error handling)
use anyhow::{Error,Result};fnrun() -> Result<()>{let res = Resources::from_relative_exe_path(Path::new("assets")).unwrap();let sdl = sdl2::init().map_err(|message| Error::msg(message))?;let video = sdl.video().map_err(|message| Error::msg(message))?;
.....
let window = video
.window("Game",900,700).opengl().resizable().build()?;let _gl_context = window
.gl_create_context().map_err(|message| Error::msg(message))?;
....
let shader_program = render_gl::Program::from_res(&gl,&res,"shaders/triangle")?;
...// Main looplet mut event_pump = sdl.event_pump().map_err(|message| Error::msg(message))?;'main:loop{
...}Ok(())}
rust-lang-deprecated/failure#347
The text was updated successfully, but these errors were encountered: