Add THROW_[MF]ALERT[EC] (AIArgs, AIAlert, AIAlertCode, AIAlertPrefix, AIAlertLine)
A system to throw errors that allow for easy error reporting to the user by showing a translated pop-up alert box with the error message. The messages use strings.xml for translation and allow the usual replacement args (ie [FILE] is replaced with a filename). The exceptions can be cascaded, by adding more (translated) text when caught and then re-throwing the result. Macros are being used to support adding a function name prefix to a message of the current function that the exception is thrown from. The syntax is: <macro>(<line>); to show 'line' <macro>(<alert>, <line>); to append 'line' to a caught alert. <macro>(<line>, <alert>); to prepend 'line' to a caught alert. where <macro> is one of: THROW_ALERT, THROW_MALERT, THROW_FALERT, THROW_FMALERT, THROW_ALERTE, THROW_MALERTE, THROW_FALERTE, THROW_FMALERTE, where M = modal, F = Function name. and where <line> is one of: <xmldesc> <xmldesc>, AIArgs<args> where <xmldesc> is a string literal that will be looked up in strings.xml, and <args> is: (<key>, <replacement>)[<args>] There are more variations of the macros to throw an arbitrary class (append _CLASS), include an int code (append C) or to store the current errno as code (append E). For example, THROW_MALERTC(code, ...), or THROW_FALERT_CLASS(Foobar, ...), where the ... is the same as for the macros above. Documentation and example usage has been added to aialert.h.
This commit is contained in:
@@ -133,6 +133,20 @@
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<notification
|
||||
icon="alert.tga"
|
||||
name="AIAlert"
|
||||
type="alert">
|
||||
[PAYLOAD]
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="alertmodal.tga"
|
||||
name="AIAlertModal"
|
||||
type="alertmodal">
|
||||
[PAYLOAD]
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="alertmodal.tga"
|
||||
name="AIXMLExportWriteError"
|
||||
|
||||
@@ -4364,4 +4364,7 @@ Try enclosing path to the editor with double quotes.
|
||||
<!-- teleport_strings.xml's strings we need -->
|
||||
<string name="completed_from">Teleport completed from</string>
|
||||
|
||||
<!-- AIAlert messages -->
|
||||
<string name="AIPrefix">"[PREFIX]: "</string>
|
||||
|
||||
</strings>
|
||||
|
||||
Reference in New Issue
Block a user