I've recently started programming with Rust. Seems like an interesting language.
Just not sure how to properly debug code, the compilers output isn't descriptive enough.
I get the following error from the compiler:
thread '' panicked at 'arithmetic operation overflowed', /home/arno/.cargo/git/checkouts/rust-mysql-simple-872ca65c96646431/master/src/io.rs:175
Process didn't exit successfully: target/debug/mysql-simple (exit code: 101)
source code:
extern crate mysql;
extern crate time;
use time::Timespec;
use std::num::Float;
use mysql::conn::{MyOpts};
use mysql::conn::pool::{MyPool};
use mysql::value::{from_value};
use std::default::{Default};
use std::f32;
struct payment {
customer_id : i32
}
fn main()
{
let opts = MyOpts{
user: Some("mysqluser".to_string()),
pass: Some("mysqluser".to_string()),
db_name: Some("dbsales".to_string()),
tcp_addr: Some("10.0.0.82".to_string()),
..Default::default()
};
let pool = MyPool::new(opts).unwrap();
let mut stmt = pool.prepare(
"SELECT customer_id
FROM
payment").unwrap();
for row in stmt.execute(&[]) {
let row = row.unwrap();
let c = payment {
customer_id : from_value(&row[0])
};
println!("{}" , c.customer_id);
}
}
How could i get detailed information on the cause of compile error?
Is the error emitted by the compiler as it compiles, or by your application when it runs? Could you paste the full command and output you're using to compile/run the application?
Ah, ok: in this case this isn't a "compile error", so much as an error that occurs in the compiled program, at runtime. cargo run will first compile the program (the same as cargo build) and then run it if compilation succeeded (which I assume it did, in this case).
It does sound like rust-mysql-simple may have an internal bug. The looking at the relevant line, it's not obvious why the number is overflowing. But... one might start debugging by running the program ./target/debug/mysql-simple in a debugger like GDB or LLDB. One could also just use tried and true "printf" debugging: make a local checkout of that repo, use paths to point to the override and then insert println! or use the macros from log (with env_logger)
It was quite obvious rust-mysql-simple bug (well.. by now, not when it was written :).
Anyway, it will be fixed in a few days with a bunch of other cleanups.
Feel free to file an issue next time, it's priceless!