Catch and prettyprint exceptions even in setup phase
This commit is contained in:
@@ -60,13 +60,28 @@ int main( int argc, char *argv[] )
|
|||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
STMClient client( ip, port, key );
|
STMClient client( ip, port, key );
|
||||||
|
|
||||||
client.init();
|
client.init();
|
||||||
|
|
||||||
|
try {
|
||||||
client.main();
|
client.main();
|
||||||
|
} catch ( Network::NetworkException e ) {
|
||||||
|
fprintf( stderr, "Network exception: %s: %s\r\n",
|
||||||
|
e.function.c_str(), strerror( e.the_errno ) );
|
||||||
|
} catch ( Crypto::CryptoException e ) {
|
||||||
|
fprintf( stderr, "Crypto exception: %s\r\n",
|
||||||
|
e.text.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
client.shutdown();
|
client.shutdown();
|
||||||
|
} catch ( Network::NetworkException e ) {
|
||||||
|
fprintf( stderr, "Network exception: %s: %s\r\n",
|
||||||
|
e.function.c_str(), strerror( e.the_errno ) );
|
||||||
|
} catch ( Crypto::CryptoException e ) {
|
||||||
|
fprintf( stderr, "Crypto exception: %s\r\n",
|
||||||
|
e.text.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
printf( "\n[mosh is exiting.]\n" );
|
printf( "\n[mosh is exiting.]\n" );
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,16 @@ int main( int argc, char *argv[] )
|
|||||||
exit( 0 );
|
exit( 0 );
|
||||||
} else {
|
} else {
|
||||||
/* parent */
|
/* parent */
|
||||||
|
try {
|
||||||
serve( master, desired_ip );
|
serve( master, desired_ip );
|
||||||
|
} catch ( Network::NetworkException e ) {
|
||||||
|
fprintf( stderr, "Network exception: %s: %s\n",
|
||||||
|
e.function.c_str(), strerror( e.the_errno ) );
|
||||||
|
} catch ( Crypto::CryptoException e ) {
|
||||||
|
fprintf( stderr, "Crypto exception: %s\n",
|
||||||
|
e.text.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( close( master ) < 0 ) {
|
if ( close( master ) < 0 ) {
|
||||||
perror( "close" );
|
perror( "close" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ void STMClient::main_init( void )
|
|||||||
|
|
||||||
void STMClient::output_new_frame( void )
|
void STMClient::output_new_frame( void )
|
||||||
{
|
{
|
||||||
|
if ( !network ) { /* clean shutdown even when not initialized */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* fetch target state */
|
/* fetch target state */
|
||||||
Terminal::Framebuffer new_state( network->get_latest_remote_state().state.get_fb() );
|
Terminal::Framebuffer new_state( network->get_latest_remote_state().state.get_fb() );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user