-
Notifications
You must be signed in to change notification settings - Fork 1
/
class.mapiexception.php
71 lines (60 loc) · 2.27 KB
/
class.mapiexception.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
* SPDX-License-Identifier: AGPL-3.0-only
* SPDX-FileCopyrightText: Copyright 2005-2016 Zarafa Deutschland GmbH
* SPDX-FileCopyrightText: Copyright 2020-2024 grommunio GmbH
*/
/**
* MAPIException
* if enabled using mapi_enable_exceptions then php-ext can throw exceptions when
* any error occurs in mapi calls. this exception will only be thrown when severity bit is set in
* error code that means it will be thrown only for mapi errors not for mapi warnings.
*/
class MAPIException extends BaseException {
/**
* Returns display message of exception if its set by the callee.
* If it is not set then we are generating some default display messages based
* on mapi error code.
*
*/
public function getDisplayMessage(): string {
if (!empty($this->displayMessage)) {
return $this->displayMessage;
}
switch ($this->getCode()) {
/* see also class.webappauthentication.php:getErrorMessage for more instances */
case MAPI_E_NO_ACCESS:
return dgettext("zarafa", "You have insufficient privileges to open this object.");
case ecUnknownUser:
case MAPI_E_LOGON_FAILED:
case MAPI_E_UNCONFIGURED:
return dgettext("zarafa", "Logon Failed. Please check your name/password.");
case MAPI_E_NETWORK_ERROR:
return dgettext("zarafa", "Can not connect to Gromox.");
case MAPI_E_UNKNOWN_ENTRYID:
return dgettext("zarafa", "Can not open object with provided id.");
case MAPI_E_NO_RECIPIENTS:
return dgettext("zarafa", "There are no recipients in the message.");
case MAPI_E_NOT_FOUND:
return dgettext("zarafa", "Can not find object.");
case MAPI_E_NOT_ENOUGH_MEMORY:
return dgettext("zarafa", "Operation failed: Server does not have enough memory.");
case MAPI_E_INTERFACE_NOT_SUPPORTED:
case MAPI_E_INVALID_PARAMETER:
case MAPI_E_INVALID_ENTRYID:
case MAPI_E_INVALID_OBJECT:
case MAPI_E_TOO_COMPLEX:
case MAPI_E_CORRUPT_DATA:
case MAPI_E_END_OF_SESSION:
case MAPI_E_AMBIGUOUS_RECIP:
case MAPI_E_COLLISION:
case MAPI_E_UNCONFIGURED:
default:
return sprintf(dgettext("zarafa", "Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode()));
}
}
}
// Tell the PHP extension which exception class to instantiate
if (function_exists('mapi_enable_exceptions')) {
mapi_enable_exceptions("mapiexception");
}