[arrayfire] 64/84: Formatting the exception string
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository arrayfire.
commit 194de52d1ca71adf526c6adccb689df8fea69aa3
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Tue Dec 29 13:29:44 2015 -0500
Formatting the exception string
---
src/api/c/err_common.cpp | 20 ++++++++++----------
src/backend/defines.hpp | 12 ++++++++----
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/api/c/err_common.cpp b/src/api/c/err_common.cpp
index 926639e..2b8a441 100644
--- a/src/api/c/err_common.cpp
+++ b/src/api/c/err_common.cpp
@@ -71,7 +71,7 @@ AfError::getError() const
AfError::~AfError() throw() {}
-TypeError::TypeError(const char * const func,
+TypeError::TypeError(const char * const func,
const char * const file,
const int line,
const int index, const af_dtype type)
@@ -90,7 +90,7 @@ int TypeError::getArgIndex() const
return argIndex;
}
-ArgumentError::ArgumentError(const char * const func,
+ArgumentError::ArgumentError(const char * const func,
const char * const file,
const int line,
const int index,
@@ -211,16 +211,16 @@ af_err processException()
try {
throw;
} catch (const DimensionError &ex) {
- ss << "In function " << ex.getFunctionName()
- << "(" << ex.getFileName() << ":" << ex.getLine() << "):\n"
+ ss << "In function " << ex.getFunctionName() << "\n"
+ << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n"
<< "Invalid dimension for argument " << ex.getArgIndex() << "\n"
<< "Expected: " << ex.getExpectedCondition() << "\n";
print_error(ss.str());
err = AF_ERR_SIZE;
} catch (const ArgumentError &ex) {
- ss << "In function " << ex.getFunctionName()
- << "(" << ex.getFileName() << ":" << ex.getLine() << "):\n"
+ ss << "In function " << ex.getFunctionName() << "\n"
+ << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n"
<< "Invalid argument at index " << ex.getArgIndex() << "\n"
<< "Expected: " << ex.getExpectedCondition() << "\n";
@@ -234,15 +234,15 @@ af_err processException()
print_error(ss.str());
err = AF_ERR_NOT_SUPPORTED;
} catch (const TypeError &ex) {
- ss << "In function " << ex.getFunctionName()
- << "(" << ex.getFileName() << ":" << ex.getLine() << "):\n"
+ ss << "In function " << ex.getFunctionName() << "\n"
+ << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n"
<< "Invalid type for argument " << ex.getArgIndex() << "\n";
print_error(ss.str());
err = AF_ERR_TYPE;
} catch (const AfError &ex) {
- ss << "Error in " << ex.getFunctionName()
- << "(" << ex.getFileName() << ":" << ex.getLine() << "):\n"
+ ss << "In function " << ex.getFunctionName() << "\n"
+ << "In file " << ex.getFileName() << ":" << ex.getLine() << "\n"
<< ex.what() << "\n";
print_error(ss.str());
diff --git a/src/backend/defines.hpp b/src/backend/defines.hpp
index a878dff..2ad71f3 100644
--- a/src/backend/defines.hpp
+++ b/src/backend/defines.hpp
@@ -14,11 +14,15 @@
inline std::string
clipFilePath(std::string path, std::string str)
{
- std::string::size_type pos = path.rfind(str);
- if(pos == std::string::npos) {
+ try {
+ std::string::size_type pos = path.rfind(str);
+ if(pos == std::string::npos) {
+ return path;
+ } else {
+ return path.substr(pos);
+ }
+ } catch(...) {
return path;
- } else {
- return path.substr(pos);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list