Skip to content

Commit

Permalink
Improved default error handler to check for nullptr sessions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-crowhurst committed Nov 5, 2015
1 parent 04f517e commit 890ee49
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/corvusoft/restbed/detail/session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ namespace restbed
{
log( Logger::Level::ERROR, String::format( "Error %i, %s", status, error.what( ) ) );

string body = error.what( );
session->close( status, body, { { "Content-Type", "text/plain" }, { "Content-Length", ::to_string( body.length( ) ) } } );
if ( session not_eq nullptr and session->is_open( ) )
{
string body = error.what( );
session->close( status, body, { { "Content-Type", "text/plain" }, { "Content-Length", ::to_string( body.length( ) ) } } );
}
}
}

Expand Down

0 comments on commit 890ee49

Please sign in to comment.