@@ -41,10 +41,20 @@ pub struct UnrecognizedWPRestError {
41
41
pub enum WPRestErrorCode {
42
42
#[ serde( rename = "rest_cannot_create_user" ) ]
43
43
CannotCreateUser ,
44
+ #[ serde( rename = "rest_cannot_delete_active_plugin" ) ]
45
+ CannotDeleteActivePlugin ,
44
46
#[ serde( rename = "rest_cannot_edit" ) ]
45
47
CannotEdit ,
46
48
#[ serde( rename = "rest_cannot_edit_roles" ) ]
47
49
CannotEditRoles ,
50
+ #[ serde( rename = "rest_cannot_install_plugin" ) ]
51
+ CannotInstallPlugin ,
52
+ #[ serde( rename = "rest_cannot_manage_plugins" ) ]
53
+ CannotManagePlugins ,
54
+ #[ serde( rename = "rest_cannot_view_plugin" ) ]
55
+ CannotViewPlugin ,
56
+ #[ serde( rename = "rest_cannot_view_plugins" ) ]
57
+ CannotViewPlugins ,
48
58
#[ serde( rename = "rest_forbidden_context" ) ]
49
59
ForbiddenContext ,
50
60
#[ serde( rename = "rest_forbidden_orderby" ) ]
@@ -53,6 +63,8 @@ pub enum WPRestErrorCode {
53
63
ForbiddenWho ,
54
64
#[ serde( rename = "rest_invalid_param" ) ]
55
65
InvalidParam ,
66
+ #[ serde( rename = "rest_plugin_not_found" ) ]
67
+ PluginNotFound ,
56
68
#[ serde( rename = "rest_not_logged_in" ) ]
57
69
Unauthorized ,
58
70
#[ serde( rename = "rest_user_cannot_delete" ) ]
@@ -69,19 +81,82 @@ pub enum WPRestErrorCode {
69
81
UserInvalidRole ,
70
82
#[ serde( rename = "rest_user_invalid_slug" ) ]
71
83
UserInvalidSlug ,
84
+ // ---
72
85
// Tested, but we believe these errors are imppossible to get unless the requests are manually modified
86
+ // ---
73
87
#[ serde( rename = "rest_user_exists" ) ]
74
88
UserExists ,
75
89
#[ serde( rename = "rest_user_invalid_argument" ) ]
76
90
UserInvalidArgument ,
77
91
#[ serde( rename = "rest_trash_not_supported" ) ]
78
92
TrashNotSupported ,
93
+ // ---
79
94
// Untested, because we believe these errors require multisite
95
+ // ---
96
+ #[ serde( rename = "rest_cannot_manage_network_plugins" ) ]
97
+ CannotManageNetworkPlugins ,
98
+ #[ serde( rename = "rest_network_only_plugin" ) ]
99
+ NetworkOnlyPlugin ,
80
100
#[ serde( rename = "rest_user_create" ) ]
81
101
UserCreate ,
102
+ // ---
82
103
// Untested, because we believe these errors are impossible to get
104
+ // ---
105
+ /// Happens while activating a plugin without the `activate_plugin` permission.
106
+ /// However, in a default setup a prior check of `activate_plugins` will fail
107
+ /// resulting in `CannotManagePlugins` error instead.
108
+ #[ serde( rename = "rest_cannot_activate_plugin" ) ]
109
+ CannotActivatePlugin ,
110
+ /// Happens while deactivating a plugin without the `deactivate_plugin` permission.
111
+ /// However, in a default setup a prior check of `activate_plugins` will fail
112
+ /// resulting in `CannotManagePlugins` error instead.
113
+ #[ serde( rename = "rest_cannot_deactivate_plugin" ) ]
114
+ CannotDeactivatePlugin ,
83
115
#[ serde( rename = "rest_user_invalid_username" ) ]
84
116
UserInvalidUsername ,
85
117
#[ serde( rename = "rest_user_invalid_password" ) ]
86
118
UserInvalidPassword ,
87
119
}
120
+
121
+ // All internal errors _should_ be wrapped as a `WPRestErrorCode` by the server. However, there
122
+ // is a good chance that some internal errors do make it into the response, so these error types
123
+ // are provided.
124
+ //
125
+ // Currently, we don't parse the response for these error types, but we could consider adding it
126
+ // as a fallback. For the moment, clients can manually try parsing an `Unrecognized` error
127
+ // into this type.
128
+ #[ derive( Debug , Deserialize , PartialEq , Eq , uniffi:: Error ) ]
129
+ pub enum WPInternalErrorCode {
130
+ #[ serde( rename = "fs_error" ) ]
131
+ FsError ,
132
+ #[ serde( rename = "fs_no_plugins_dir" ) ]
133
+ FsNoPluginsDir ,
134
+ #[ serde( rename = "fs_unavailable" ) ]
135
+ FsUnavailable ,
136
+ #[ serde( rename = "could_not_remove_plugin" ) ]
137
+ CouldNotRemovePlugin ,
138
+ #[ serde( rename = "could_not_resume_plugin" ) ]
139
+ CouldNotResumePlugin ,
140
+ #[ serde( rename = "no_plugin_header" ) ]
141
+ NoPluginHeader ,
142
+ #[ serde( rename = "plugin_missing_dependencies" ) ]
143
+ PluginMissingDependencies ,
144
+ #[ serde( rename = "plugin_not_found" ) ]
145
+ PluginNotFound ,
146
+ #[ serde( rename = "plugin_invalid" ) ]
147
+ PluginInvalid ,
148
+ #[ serde( rename = "plugin_php_incompatible" ) ]
149
+ PluginPhpIncompatible ,
150
+ #[ serde( rename = "plugin_wp_incompatible" ) ]
151
+ PluginWpIncompatible ,
152
+ #[ serde( rename = "plugin_wp_php_incompatible" ) ]
153
+ PluginWpPhpIncompatible ,
154
+ #[ serde( rename = "plugins_invalid" ) ]
155
+ PluginsInvalid ,
156
+ #[ serde( rename = "unable_to_connect_to_filesystem" ) ]
157
+ UnableToConnectToFilesystem ,
158
+ #[ serde( rename = "unable_to_determine_installed_plugin" ) ]
159
+ UnableToDetermineInstalledPlugin ,
160
+ #[ serde( rename = "unexpected_output" ) ]
161
+ UnexpectedOutput ,
162
+ }
0 commit comments