Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastian Schrader
Kea
Commits
6eb9d7e6
Commit
6eb9d7e6
authored
May 21, 2015
by
Francis Dupont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3697] added a throwTypeError macro to display position
parent
8ab6d170
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
src/lib/cc/data.cc
src/lib/cc/data.cc
+12
-12
src/lib/cc/data.h
src/lib/cc/data.h
+20
-7
No files found.
src/lib/cc/data.cc
View file @
6eb9d7e6
// Copyright (C) 2010, 2014 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2010, 2014
, 2015
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -136,57 +136,57 @@ Element::setValue(const std::map<std::string, ConstElementPtr>&) {
ConstElementPtr
Element
::
get
(
const
int
)
const
{
isc_throw
(
TypeError
,
"get(int) called on a non-list Element"
);
throwTypeError
(
"get(int) called on a non-list Element"
);
}
void
Element
::
set
(
const
size_t
,
ConstElementPtr
)
{
isc_throw
(
TypeError
,
"set(int, element) called on a non-list Element"
);
throwTypeError
(
"set(int, element) called on a non-list Element"
);
}
void
Element
::
add
(
ConstElementPtr
)
{
isc_throw
(
TypeError
,
"add() called on a non-list Element"
);
throwTypeError
(
"add() called on a non-list Element"
);
}
void
Element
::
remove
(
const
int
)
{
isc_throw
(
TypeError
,
"remove(int) called on a non-list Element"
);
throwTypeError
(
"remove(int) called on a non-list Element"
);
}
size_t
Element
::
size
()
const
{
isc_throw
(
TypeError
,
"size() called on a non-list Element"
);
throwTypeError
(
"size() called on a non-list Element"
);
}
bool
Element
::
empty
()
const
{
isc_throw
(
TypeError
,
"empty() called on a non-list Element"
);
throwTypeError
(
"empty() called on a non-list Element"
);
}
ConstElementPtr
Element
::
get
(
const
std
::
string
&
)
const
{
isc_throw
(
TypeError
,
"get(string) called on a non-map Element"
);
throwTypeError
(
"get(string) called on a non-map Element"
);
}
void
Element
::
set
(
const
std
::
string
&
,
ConstElementPtr
)
{
isc_throw
(
TypeError
,
"set(name, element) called on a non-map Element"
);
throwTypeError
(
"set(name, element) called on a non-map Element"
);
}
void
Element
::
remove
(
const
std
::
string
&
)
{
isc_throw
(
TypeError
,
"remove(string) called on a non-map Element"
);
throwTypeError
(
"remove(string) called on a non-map Element"
);
}
bool
Element
::
contains
(
const
std
::
string
&
)
const
{
isc_throw
(
TypeError
,
"contains(string) called on a non-map Element"
);
throwTypeError
(
"contains(string) called on a non-map Element"
);
}
ConstElementPtr
Element
::
find
(
const
std
::
string
&
)
const
{
isc_throw
(
TypeError
,
"find(string) called on a non-map Element"
);
throwTypeError
(
"find(string) called on a non-map Element"
);
}
bool
...
...
src/lib/cc/data.h
View file @
6eb9d7e6
// Copyright (C) 2010, 2014 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2010, 2014
, 2015
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -186,6 +186,19 @@ public:
std
::
string
toWire
()
const
;
void
toWire
(
std
::
ostream
&
out
)
const
;
/// \brief Add the position to a TypeError message
/// should be used in place of isc_throw(TypeError, error)
#define throwTypeError(error) \
{ \
std::string msg_ = error; \
if ((position_.file_ != "") || \
(position_.line_ != 0) || \
(position_.pos_ != 0)) { \
msg_ += " in " + position_.str(); \
} \
isc_throw(TypeError, msg_); \
}
/// \name pure virtuals, every derived class must implement these
/// \return true if the other ElementPtr has the same type and value
...
...
@@ -204,20 +217,20 @@ public:
/// getValue() below
//@{
virtual
int64_t
intValue
()
const
{
isc_throw
(
TypeError
,
"intValue() called on non-integer Element"
);
};
{
throwTypeError
(
"intValue() called on non-integer Element"
);
};
virtual
double
doubleValue
()
const
{
isc_throw
(
TypeError
,
"doubleValue() called on non-double Element"
);
};
{
throwTypeError
(
"doubleValue() called on non-double Element"
);
};
virtual
bool
boolValue
()
const
{
isc_throw
(
TypeError
,
"boolValue() called on non-Bool Element"
);
};
{
throwTypeError
(
"boolValue() called on non-Bool Element"
);
};
virtual
std
::
string
stringValue
()
const
{
isc_throw
(
TypeError
,
"stringValue() called on non-string Element"
);
};
{
throwTypeError
(
"stringValue() called on non-string Element"
);
};
virtual
const
std
::
vector
<
ConstElementPtr
>&
listValue
()
const
{
// replace with real exception or empty vector?
isc_throw
(
TypeError
,
"listValue() called on non-list Element"
);
throwTypeError
(
"listValue() called on non-list Element"
);
};
virtual
const
std
::
map
<
std
::
string
,
ConstElementPtr
>&
mapValue
()
const
{
// replace with real exception or empty map?
isc_throw
(
TypeError
,
"mapValue() called on non-map Element"
);
throwTypeError
(
"mapValue() called on non-map Element"
);
};
//@}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment