Panic message is printed with fmt::Debug formatter, and impl fmt::Debug for str prints with Debug escaping which tries to print it like a string literal.
Note that debug print format is explicitly not stable, it may change in the future without warning. Any code that tries to parse it may subject to break in long-term scenario.
Yes it has been converted to a string, but set_hook disables the default of debug printing that string and allows you to display print it instead (or error! it into your logging library).
EDIT: oh, you mean the unwrap has debug printed the error already... that is a problem. I guess the other local workaround would be to wrap the string in a newtype that forwards debug to display when creating the error.
The idiomatic solution would be to return the error to somewhere that can handle it, and have the main function handle top-level errors by printing them in the way you want them printed.
That said, you could cheat by wrapping your error in one of these, which explicitly uses the Display implementation inside the Debug impl block.
Mostly I want to quit on errors anyway. So as far as I am concerned, all this error handling is more bother than what it is worth. I wish there was a way to turn it all off altogether.
I have yet to see any error recovery where it is actually meaningful and not misleading to continue with some different tack of computation afterwards (the stated reason for all this baggage).
So, my simple solution, good enough for the vast majority of my needs is:
eprintln!("function-name: my own error message {} {}",var1,var2,...);
panic!();
The output of this actually looks neat, unlike the rusty errors. Also, panic!(); returns the line-number, which together with my own proper error message is all the information I need.