Skip to content

Commit b94045a

Browse files
committed
fix: rename AccessError to Error
1 parent d6c8b1d commit b94045a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

sentry/src/access.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ use primitives::event_submission::{RateLimit, Rule};
77
use primitives::sentry::Event;
88
use primitives::Channel;
99
use std::cmp::PartialEq;
10-
use std::error::Error;
10+
use std::error;
1111
use std::fmt;
1212

1313
#[derive(Debug, PartialEq, Eq)]
14-
pub enum AccessError {
14+
pub enum Error {
1515
OnlyCreatorCanCloseChannel,
1616
ChannelIsExpired,
1717
ChannelIsInWithdrawPeriod,
1818
RulesError(String),
1919
}
2020

21-
impl Error for AccessError {}
21+
impl error::Error for Error {}
2222

23-
impl fmt::Display for AccessError {
23+
impl fmt::Display for Error {
2424
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2525
match self {
26-
AccessError::OnlyCreatorCanCloseChannel => write!(f, "only creator can create channel"),
27-
AccessError::ChannelIsExpired => write!(f, "channel has expired"),
28-
AccessError::ChannelIsInWithdrawPeriod => write!(f, "channel is in withdraw period"),
29-
AccessError::RulesError(error) => write!(f, "{}", error),
26+
Error::OnlyCreatorCanCloseChannel => write!(f, "only creator can create channel"),
27+
Error::ChannelIsExpired => write!(f, "channel has expired"),
28+
Error::ChannelIsInWithdrawPeriod => write!(f, "channel is in withdraw period"),
29+
Error::RulesError(error) => write!(f, "{}", error),
3030
}
3131
}
3232
}
@@ -38,7 +38,7 @@ pub async fn check_access(
3838
rate_limit: &RateLimit,
3939
channel: &Channel,
4040
events: &[Event],
41-
) -> Result<(), AccessError> {
41+
) -> Result<(), Error> {
4242
let is_close_event = |e: &Event| match e {
4343
Event::Close => true,
4444
_ => false,
@@ -47,7 +47,7 @@ pub async fn check_access(
4747
let is_in_withdraw_period = current_time > channel.spec.withdraw_period_start;
4848

4949
if current_time > channel.valid_until {
50-
return Err(AccessError::ChannelIsExpired);
50+
return Err(Error::ChannelIsExpired);
5151
}
5252

5353
// We're only sending a CLOSE
@@ -60,11 +60,11 @@ pub async fn check_access(
6060

6161
// Only the creator can send a CLOSE
6262
if session.uid != channel.creator && events.iter().any(is_close_event) {
63-
return Err(AccessError::OnlyCreatorCanCloseChannel);
63+
return Err(Error::OnlyCreatorCanCloseChannel);
6464
}
6565

6666
if is_in_withdraw_period {
67-
return Err(AccessError::ChannelIsInWithdrawPeriod);
67+
return Err(Error::ChannelIsInWithdrawPeriod);
6868
}
6969

7070
let default_rules = [
@@ -106,7 +106,7 @@ pub async fn check_access(
106106
);
107107

108108
if let Err(rule_error) = apply_all_rules.await {
109-
Err(AccessError::RulesError(rule_error))
109+
Err(Error::RulesError(rule_error))
110110
} else {
111111
Ok(())
112112
}
@@ -239,7 +239,7 @@ mod test {
239239
let err_response =
240240
check_access(&redis, &session, &config.ip_rate_limit, &channel, &events).await;
241241
assert_eq!(
242-
Err(AccessError::RulesError(
242+
Err(Error::RulesError(
243243
"rateLimit: too many requests".to_string()
244244
)),
245245
err_response
@@ -275,7 +275,7 @@ mod test {
275275
.await;
276276

277277
assert_eq!(
278-
Err(AccessError::RulesError(
278+
Err(Error::RulesError(
279279
"rateLimit: only allows 1 event".to_string()
280280
)),
281281
err_response

0 commit comments

Comments
 (0)