-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from driplineorg/dl3/exception-integration
Dl3/exception integration
- Loading branch information
Showing
15 changed files
with
80 additions
and
137 deletions.
There are no files selected for viewing
Submodule dripline-cpp
updated
4 files
+2 −0 | .dockerignore | |
+1 −1 | CMakeLists.txt | |
+13 −0 | library/return_codes.cc | |
+1 −0 | library/return_codes.hh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
__all__ = [] | ||
|
||
from _dripline.core import get_return_codes_map | ||
|
||
__all__.append("get_return_codes_dict") | ||
def get_return_codes_dict(): | ||
''' | ||
Construct a dictionary of return codes, keyed on names (snake_case) | ||
NOTE: return codes can be dynamically added at runtime, this function returns the current set when it is called; you probably when to call it when you need the codes rather than creating the dict earlier. | ||
''' | ||
return {a_return_code.name:a_return_code for (_, a_return_code) in get_return_codes_map().items()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
__all__ = [] | ||
|
||
import scarab | ||
from _dripline.core import _ThrowReply, DL_Success, set_reply_cache | ||
from _dripline.core import DL_Success, set_reply_cache | ||
from .return_codes import get_return_codes_dict | ||
|
||
__all__.append('ThrowReply') | ||
class ThrowReply(Exception): | ||
def __init__(self, return_code=DL_Success(), message=DL_Success().description, payload=scarab.Param()): | ||
Exception.__init__(self) | ||
''' | ||
return_code (_dripline.core.ReturnCode || string) : either a ReturnCode object, or the string name of a return code | ||
message (string) : string to pass into the exception object, provides clarification of the particular exception | ||
payload (scarab.Param) : any data to include in the payload of the reply message (in a Warning, should match the normal success data) | ||
''' | ||
Exception.__init__(self, message) | ||
if isinstance(return_code, str): | ||
return_code = get_return_codes_dict()[return_code] | ||
set_reply_cache(return_code, message, payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef DRIPLINE_PYBIND_REPLY_CACHE_HH_ | ||
#define DRIPLINE_PYBIND_REPLY_CACHE_HH_ | ||
|
||
#include "reply_cache.hh" | ||
|
||
#include "pybind11/pybind11.h" | ||
#include "pybind11/iostream.h" | ||
|
||
namespace dripline_pybind | ||
{ | ||
|
||
std::list< std::string> export_throw_reply( pybind11::module& mod ) | ||
{ | ||
std::list< std::string > all_items; | ||
|
||
all_items.push_back( "set_reply_cache" ); | ||
mod.def( "set_reply_cache", | ||
[](const dripline::return_code& a_code, const std::string& a_message, const scarab::param& a_payload) { | ||
dripline::set_reply_cache( a_code, a_message, a_payload.clone()); | ||
}, | ||
pybind11::arg( "return_code" ), | ||
pybind11::arg( "return_message" ), | ||
pybind11::arg( "payload" ), | ||
"set the reply cache with the desired information" | ||
); | ||
|
||
return all_items; | ||
} | ||
} /* namespace dripline_pybind */ | ||
|
||
#endif /* DRIPLINE_PYBIND_REPLY_CACHE_HH_ */ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.