-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Rotter
committed
Feb 3, 2021
1 parent
c53b4bb
commit a94c016
Showing
14 changed files
with
466 additions
and
273 deletions.
There are no files selected for viewing
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,39 @@ | ||
// For license of this file, see <project-root-folder>/LICENSE.md. | ||
|
||
#include "exceptions/scriptexception.h" | ||
|
||
#include "definitions/definitions.h" | ||
|
||
ScriptException::ScriptException(Reason reason, QString message) : ApplicationException(message), m_reason(reason) { | ||
if (message.isEmpty()) { | ||
setMessage(messageForReason(reason)); | ||
} | ||
else if (reason == ScriptException::Reason::InterpreterError || | ||
reason == ScriptException::Reason::OtherError) { | ||
setMessage(messageForReason(reason) + QSL(": '%1'").arg(message)); | ||
} | ||
} | ||
|
||
ScriptException::Reason ScriptException::reason() const { | ||
return m_reason; | ||
} | ||
|
||
QString ScriptException::messageForReason(ScriptException::Reason reason) const { | ||
switch (reason) { | ||
case ScriptException::Reason::ExecutionLineInvalid: | ||
return tr("script line is not well-formed"); | ||
|
||
case ScriptException::Reason::InterpreterError: | ||
return tr("script threw an error"); | ||
|
||
case ScriptException::Reason::InterpreterNotFound: | ||
return tr("script's interpreter was not found"); | ||
|
||
case ScriptException::Reason::InterpreterTimeout: | ||
return tr("script execution took too long"); | ||
|
||
case ScriptException::Reason::OtherError: | ||
default: | ||
return tr("unknown error"); | ||
} | ||
} |
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,33 @@ | ||
// For license of this file, see <project-root-folder>/LICENSE.md. | ||
|
||
#ifndef SCRIPTEXCEPTION_H | ||
#define SCRIPTEXCEPTION_H | ||
|
||
#include "exceptions/applicationexception.h" | ||
|
||
#include <QCoreApplication> | ||
|
||
class ScriptException : public ApplicationException { | ||
Q_DECLARE_TR_FUNCTIONS(ScriptException) | ||
|
||
public: | ||
enum class Reason { | ||
ExecutionLineInvalid, | ||
InterpreterNotFound, | ||
InterpreterError, | ||
InterpreterTimeout, | ||
OtherError | ||
}; | ||
|
||
explicit ScriptException(Reason reason = Reason::OtherError, QString message = QString()); | ||
|
||
Reason reason() const; | ||
|
||
private: | ||
QString messageForReason(Reason reason) const; | ||
|
||
private: | ||
Reason m_reason; | ||
}; | ||
|
||
#endif // SCRIPTEXCEPTION_H |
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
Oops, something went wrong.