xref: /trafficserver/include/ts/TsException.h (revision 774f55f1)
1 /** @file
2 
3     A brief file description
4 
5     @section license License
6 
7     Licensed to the Apache Software Foundation (ASF) under one
8     or more contributor license agreements.  See the NOTICE file
9     distributed with this work for additional information
10     regarding copyright ownership.  The ASF licenses this file
11     to you under the Apache License, Version 2.0 (the
12     "License"); you may not use this file except in compliance
13     with the License.  You may obtain a copy of the License at
14 
15     http://www.apache.org/licenses/LICENSE-2.0
16 
17     Unless required by applicable law or agreed to in writing, software
18     distributed under the License is distributed on an "AS IS" BASIS,
19     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20     See the License for the specific language governing permissions and
21     limitations under the License.
22 */
23 
24 #pragma once
25 
26 /** @file
27     Apache Traffic Server Exceptions.
28  */
29 
30 #include <stddef.h>
31 #include <unistd.h>
32 
33 namespace ts
34 {
35 /** Base class for ATS exception.
36     Clients should subclass as appropriate. This is intended to carry
37     pre-allocated text along so that it can be thrown without any
38     additional memory allocation.
39 */
40 class Exception
41 {
42 public:
43   /// Default constructor.
44   Exception();
45   /// Construct with alternate @a text.
46   Exception(const char *text ///< Alternate text for exception.
47   );
48 
49   static const char *const DEFAULT_TEXT;
50 
51 protected:
52   const char *m_text;
53 };
54 
55 // ----------------------------------------------------------
56 // Inline implementations.
57 
Exception()58 inline Exception::Exception() : m_text(DEFAULT_TEXT) {}
Exception(const char * text)59 inline Exception::Exception(const char *text) : m_text(text) {}
60 } // namespace ts
61