/* Copyright 2017 The MathWorks, Inc. */ #ifndef __MEX_EXCEPTION_IMPL_CPP_HPP__ #define __MEX_EXCEPTION_IMPL_CPP_HPP__ #include "cppmex/mexException.hpp" #include "mexEngineUtilImpl.hpp" #include namespace matlab { namespace engine { /* MATLABException */ inline Exception::Exception() :std::exception() {} inline Exception::Exception(const std::string& msg) : message(msg) {} inline Exception::~Exception() {} inline Exception& Exception::operator=(const Exception& rhs) { message = rhs.message; return *this; } inline const char* Exception::what() const NOEXCEPT { return message.c_str(); } /* MATLABSyntaxException */ inline MATLABException::MATLABException() : Exception() {} inline MATLABException::~MATLABException() {}; inline MATLABException::MATLABException(const std::string& msg) : Exception(msg) {} inline MATLABException::MATLABException(const std::string& id, const std::basic_string& txt):Exception(convertUTF16StringToUTF8String(txt)), errorID(id), errorText(txt) {} inline MATLABException::MATLABException(const MATLABException& rhs) : Exception(convertUTF16StringToUTF8String(rhs.errorText)), errorID(rhs.errorID), errorText(rhs.errorText) {} inline MATLABException& MATLABException::operator=(const MATLABException& rhs) { Exception::operator=(convertUTF16StringToUTF8String(rhs.errorText)); errorID = rhs.errorID; errorText = rhs.errorText; return *this; } inline std::string MATLABException::getMessageID() const { return errorID; } inline std::basic_string MATLABException::getMessageText() const { return errorText; } /* MATLABSyntaxException */ inline MATLABSyntaxException::MATLABSyntaxException(const std::string& msg) : MATLABException(msg) {} inline MATLABSyntaxException::MATLABSyntaxException(const std::string& id, const std::basic_string& txt) : MATLABException(id, txt) {} /* MATLABExecutionException */ inline MATLABExecutionException::MATLABExecutionException() : MATLABException() {} inline MATLABExecutionException::MATLABExecutionException(const std::string& msg, const std::vector& trace) : MATLABException(msg), stackTrace(trace) {} inline MATLABExecutionException::MATLABExecutionException(const std::string& id, const std::basic_string& txt, const std::vector& trace, const std::vector& cause) : MATLABException(id, txt), stackTrace(trace), errorCause(cause) {} inline std::vector MATLABExecutionException::getStackTrace() const { return stackTrace; } inline std::vector MATLABExecutionException::getCause() const { return errorCause; } inline void MATLABExecutionException::setCause(const std::vector& cause) { errorCause = cause; } /* TypeConversionException */ inline TypeConversionException::TypeConversionException() : Exception() {} inline TypeConversionException::TypeConversionException(const std::string& msg) : Exception(msg) {} /* StackFrame */ inline StackFrame::StackFrame() {} inline StackFrame::StackFrame(const std::basic_string& file, const std::basic_string& func, uint64_t line) :fileName(file), funcName(func), lineNumber(line) {} inline std::basic_string StackFrame::getFileName() const { return fileName; } inline std::basic_string StackFrame::getFunctionName() const { return funcName; } inline uint64_t StackFrame::getLineNumber() const { return lineNumber; } inline CancelledException::CancelledException() : MATLABException() {} inline CancelledException::~CancelledException() {} inline CancelledException::CancelledException(const std::string& id, const std::u16string& msg) : MATLABException(id, msg) {} inline InterruptedException::InterruptedException() : MATLABException() {} inline InterruptedException::~InterruptedException() {} inline InterruptedException::InterruptedException(const std::string& id, const std::u16string& msg) : MATLABException(id, msg) {} } } #endif