comparison Core/HttpServer/MongooseServer.cpp @ 2954:d924f9bb61cc

taking advantage of details in OrthancException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Dec 2018 14:35:34 +0100
parents 1153b1a128fe
children 4e43e67f8ecf
comparison
equal deleted inserted replaced
2953:210d5afd8f2b 2954:d924f9bb61cc
811 throw; // Pass the exception to the main handler below 811 throw; // Pass the exception to the main handler below
812 } 812 }
813 // Now convert native exceptions as OrthancException 813 // Now convert native exceptions as OrthancException
814 catch (boost::bad_lexical_cast&) 814 catch (boost::bad_lexical_cast&)
815 { 815 {
816 LOG(ERROR) << "Syntax error in some user-supplied data"; 816 throw OrthancException(ErrorCode_BadParameterType,
817 throw OrthancException(ErrorCode_BadParameterType); 817 "Syntax error in some user-supplied data");
818 } 818 }
819 catch (std::runtime_error&) 819 catch (std::runtime_error&)
820 { 820 {
821 // Presumably an error while parsing the JSON body 821 // Presumably an error while parsing the JSON body
822 throw OrthancException(ErrorCode_BadRequest); 822 throw OrthancException(ErrorCode_BadRequest);
823 } 823 }
824 catch (std::bad_alloc&) 824 catch (std::bad_alloc&)
825 { 825 {
826 LOG(ERROR) << "The server hosting Orthanc is running out of memory"; 826 throw OrthancException(ErrorCode_NotEnoughMemory,
827 throw OrthancException(ErrorCode_NotEnoughMemory); 827 "The server hosting Orthanc is running out of memory");
828 } 828 }
829 catch (...) 829 catch (...)
830 { 830 {
831 LOG(ERROR) << "An unhandled exception was generated inside the HTTP server"; 831 throw OrthancException(ErrorCode_InternalError,
832 throw OrthancException(ErrorCode_InternalError); 832 "An unhandled exception was generated inside the HTTP server");
833 } 833 }
834 } 834 }
835 catch (OrthancException& e) 835 catch (OrthancException& e)
836 { 836 {
837 assert(server != NULL); 837 assert(server != NULL);