Skip to content

Commit 111bf75

Browse files
authored
Merge pull request rscarson#263 from rscarson/rscarson-patch-1
Expose PermissionDenied
2 parents 3b05e9a + 21ccd38 commit 111bf75

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/ext/web/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ pub use options::WebOptions;
88
mod permissions;
99
pub(crate) use permissions::PermissionsContainer;
1010
pub use permissions::{
11-
AllowlistWebPermissions, DefaultWebPermissions, SystemsPermissionKind, WebPermissions,
11+
AllowlistWebPermissions, DefaultWebPermissions, PermissionDenied, SystemsPermissionKind,
12+
WebPermissions,
1213
};
1314

1415
extension!(

src/ext/web/permissions.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ use std::{
1111
/// This type is needed since `deno_permissions` does not expose any way to
1212
/// externally create a `PermissionCheckError`
1313
pub struct PermissionDenied {
14+
/// The resource being accessed
1415
pub access: String,
16+
17+
/// The reason or kind of denial
1518
pub name: &'static str,
1619
}
1720
impl PermissionDenied {
21+
/// Create a new error
1822
pub fn new(access: impl ToString, reason: &'static str) -> Self {
1923
Self {
2024
access: access.to_string(),
2125
name: reason,
2226
}
2327
}
2428

29+
/// Resolved to an Err(Self) with a generic "Not Allowed" message
2530
pub fn oops<T>(access: impl ToString) -> Result<T, Self> {
2631
Err(Self::new(access, "Not Allowed"))
2732
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ pub use ext::node::RustyResolver;
316316

317317
#[cfg(feature = "web")]
318318
pub use ext::web::{
319-
AllowlistWebPermissions, DefaultWebPermissions, SystemsPermissionKind, WebOptions,
320-
WebPermissions,
319+
AllowlistWebPermissions, DefaultWebPermissions, PermissionDenied, SystemsPermissionKind,
320+
WebOptions, WebPermissions,
321321
};
322322
pub use ext::ExtensionOptions;
323323

0 commit comments

Comments
 (0)