Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
ClientErrorException.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
7
9
10 /*
11 ********************************************************************************
12 ************************* HTTP::ClientErrorException ***************************
13 ********************************************************************************
14 */
15 inline ClientErrorException::ClientErrorException (Status status, const String& reason)
16 : inherited{status, reason}
17 {
18 Require (400 <= status and status < 500);
19 }
20 inline ClientErrorException::ClientErrorException (const String& reason)
21 : ClientErrorException{StatusCodes::kBadRequest, reason}
22 {
23 }
24 template <invocable FUNCTION, typename RESULT_TYPE>
25 inline RESULT_TYPE ClientErrorException::TreatExceptionsAsClientError (FUNCTION&& f)
26 {
27 try {
28 return forward<FUNCTION> (f) ();
29 }
30 catch (const ClientErrorException&) {
31 Execution::ReThrow (); // if it already is one, just rethrow
32 }
33 catch (...) {
34 using namespace Characters;
35 DbgTrace ("Translating exception {} to ClientErrorException"_f, current_exception ());
36 Execution::Throw (ClientErrorException{current_exception ()});
37 }
38 }
39
40}
#define DbgTrace
Definition Trace.h:309
ClientErrorException is to capture exceptions caused by a bad (e.g ill-formed) request.