spiegel-keyman/windows/src/engine/kmcomapi/util/exception_keyman.pas
Marc Durdin b65b982584 Keyman Desktop and Keyman Developer open source 10.0 alpha seed (#121)
* Keyman for Windows 10.0 Open Source

* Squashed 'windows/src/ext/jedi/jedi/' content from commit f444ad2

git-subtree-dir: windows/src/ext/jedi/jedi
git-subtree-split: f444ad2da4693851e523f1ea6bd541f701904c24

* Squashed 'windows/src/ext/jedi/jcl/' content from commit d63d3c9fd

git-subtree-dir: windows/src/ext/jedi/jcl
git-subtree-split: d63d3c9fd9ff84efdd8159084ec6a60313644243

* Squashed 'windows/src/ext/jedi/jvcl/' content from commit bee19f3b4

git-subtree-dir: windows/src/ext/jedi/jvcl
git-subtree-split: bee19f3b46909fde2fa92c06cd2706f41d99f6c3

* Add required .res files

* Add required .res files

* Add docbook files (forced)

* Add required libxslt

* Add required jedi files

* Add installation files

* Tweak .gitignore for open

* CI

* Remove KMW from Developer source (#122)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Fixup release build and copy license, readme from kmw during build

* Remove obsolete build help documentation

* Keyman Engine 10 on Windows regression for shift states (#129)

* Improve #128 -- cleaner debug messages

* Fixes #127, shift state now resets correctly; and more work for #128

* Fixes #130 (#131)
2017-07-25 10:53:06 +07:00

65 lines
2.2 KiB
ObjectPascal

(*
Name: exception_keyman
Copyright: Copyright (C) 2003-2017 SIL International.
Documentation:
Description:
Create Date: 2 Feb 2012
Modified Date: 4 Nov 2012
Authors: mcdurdin
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History: 02 Feb 2012 - mcdurdin - I3183 - Add debug info when tracing Keyman COM API errors
04 Nov 2012 - mcdurdin - I3530 - V9.0 - Merge of I3183 - Report clearer error when failure to register controller window
*)
unit exception_keyman;
interface
uses SysUtils, windows, activex, comobj, keymanerrorcodes;
type
EKeyman = class(EOleException)
constructor Create(const Source, WindowsMessage: string; ErrorCode: Cardinal); // I3183 // I3530
constructor CreateFmt(const Source, WindowsMessage: string; ErrorCode: Cardinal; AArgs: OleVariant); // I3183 // I3530
end;
function GetKeymanErrorMessage(const Source: string; ErrorCode: Cardinal): TKeymanErrorInfo;
implementation
uses
utilvararray;
function GetKeymanErrorMessage(const Source: string; ErrorCode: Cardinal): TKeymanErrorInfo;
begin
if ((Cardinal(ErrorCode) >= Cardinal(KMN_E_BASE)) and (Cardinal(ErrorCode) <= Cardinal(KMN_E_LAST))) or
((Cardinal(ErrorCode) >= Cardinal(KMN_W_BASE)) and (Cardinal(ErrorCode) <= Cardinal(KMN_W_LAST))) then
Result := KeymanErrors[ErrorCode and $FFFF]
else
begin
Result.Message := SysErrorMessage(ErrorCode) + ', '+IntToStr(ErrorCode); // I3183 // I3530
Result.Source := Source;
Result.HelpContext := 0;
end;
end;
{ EKeyman }
constructor EKeyman.Create(const Source, WindowsMessage: string; ErrorCode: Cardinal); // I3183 // I3530
begin
with GetKeymanErrorMessage(Source, ErrorCode) do
inherited Create(ClassName+' '+Message, ErrorCode, Source, 'kmcomapi.hlp', HelpContext);
end;
constructor EKeyman.CreateFmt(const Source, WindowsMessage: string; ErrorCode: Cardinal; AArgs: OleVariant); // I3183 // I3530
begin
with GetKeymanErrorMessage(Source, ErrorCode) do
inherited Create(FormatVariant(Message, AArgs), ErrorCode, Source, 'kmcomapi.hlp', HelpContext);
end;
end.