Skip to content

Commit 482e0ac

Browse files
authored
Update README.md
1 parent c9d6917 commit 482e0ac

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

README.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ WinToast is a lightly library written in C++ which brings a complete integration
1717
Toast notifications allows your app to inform the users about relevant information and timely events that they should see and take action upon inside your app, such as a new instant message, a new friend request, breaking news, or a calendar event.
1818

1919
1. [Toast Templates](#id1)
20-
2. [Error Handling](#id2)
21-
3. [Event Handler](#id3)
22-
4. [Expiration Time](#id4)
23-
5. [Modern Features](#id5)
20+
2. [Event Handler](#id3)
21+
3. [Expiration Time](#id4)
22+
4. [Modern Features](#id5)
23+
5. [Error Handling](#id2)
2424
6. [Example of usage](#id6)
2525

2626
<div id='id1' />
@@ -51,12 +51,6 @@ templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
5151

5252
*The user can use the default system sound or specify a sound to play when a toast notification is displayed. Same behavior for the toast notification image, by default Windows try to use the app icon.*
5353

54-
<div id='id2' />
55-
## Error Handling
56-
57-
58-
59-
6054
<div id='id3' />
6155

6256
## Event Handler
@@ -129,6 +123,46 @@ WinToast::instance()->showToast(templ, handler)
129123
130124
***By default, WinToast checks if your systems support the features, ignoring the not supported ones.***
131125

126+
<div id='id2' />
127+
128+
## Error Handling
129+
There are several reasons WinToast can fail that's why the library notifies caller about fail reason. Those are the code for each failure:
130+
131+
| WinToastError | Error Code | Error message |
132+
|--|--|--|
133+
| NoError | 0x00 | No error. The process was executed correctly |
134+
| NotInitialized | 0x01 | The library has not been initialized |
135+
| SystemNotSupported | 0x02 | The OS does not support WinToast |
136+
| ShellLinkNotCreated | 0x03 | The library was not able to create a Shell Link for the app |
137+
| InvalidAppUserModelID | 0x04 | The AUMI is not a valid one |
138+
| InvalidParameters | 0x05 | The parameters used to configure the library are not valid normally because an invalid AUMI or App Name |
139+
| NotDisplayed | 0x06 | The toast was created correctly but WinToast was not able to display the toast |
140+
| UnknownError | 0x07 | Unknown error |
141+
142+
A common example of usage is to check while initializing the library or showing a toast notification the possible failure code:
143+
144+
```cpp
145+
WinToast::WinToastError error;
146+
const bool succedded = WinToast::instance()->initialize(&error);
147+
if (!succedded) {
148+
std::wcout << L"Error, could not initialize the lib. Error number: "
149+
<< error << std::endl;
150+
}
151+
...
152+
// Configure the template
153+
...
154+
const bool launched = WinToast::instance()->showToast(templ, handler, &error);
155+
if (!launched) {
156+
std::wcout << L"Error: Could not launch your toast notification. Error: "
157+
<< error << std::endl;
158+
}
159+
```
160+
161+
162+
163+
164+
165+
132166
<div id='id6' />
133167
134168
## Example of Usage

0 commit comments

Comments
 (0)