Skip to content

Commit c0d3340

Browse files
authored
util/errors: Simplify internal() fn (#5878)
1 parent 7180f15 commit c0d3340

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

src/controllers/crate_owner_invitation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub async fn list(req: ConduitRequest) -> AppResult<Json<Value>> {
3333
invited_by_username: users
3434
.iter()
3535
.find(|u| u.id == private.inviter_id)
36-
.ok_or_else(|| internal(&format!("missing user {}", private.inviter_id)))?
36+
.ok_or_else(|| internal(format!("missing user {}", private.inviter_id)))?
3737
.login
3838
.clone(),
3939
invitee_id: private.invitee_id,
@@ -217,7 +217,7 @@ fn prepare_list<B>(
217217
crate_id: invitation.crate_id,
218218
crate_name: crate_names
219219
.get(&invitation.crate_id)
220-
.ok_or_else(|| internal(&format!("missing crate with id {}", invitation.crate_id)))?
220+
.ok_or_else(|| internal(format!("missing crate with id {}", invitation.crate_id)))?
221221
.clone(),
222222
created_at: invitation.created_at,
223223
expires_at: invitation.expires_at(config),

src/github.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ fn handle_error_response(error: &reqwest::Error) -> BoxedAppError {
165165
GitHub org memberships.",
166166
),
167167
Some(Status::NOT_FOUND) => not_found(),
168-
_ => internal(&format_args!(
169-
"didn't get a 200 result from github: {error}"
170-
)),
168+
_ => internal(format!("didn't get a 200 result from github: {error}")),
171169
}
172170
}
173171

src/uploaders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl Uploader {
205205
extra_headers,
206206
UploadBucket::Default,
207207
)
208-
.map_err(|e| internal(&format_args!("failed to upload crate: {e}")))?;
208+
.map_err(|e| internal(format!("failed to upload crate: {e}")))?;
209209
Ok(())
210210
}
211211

src/util/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl AppError for InternalAppErrorStatic {
327327
}
328328
}
329329

330-
pub fn internal<S: ToString + ?Sized>(error: &S) -> BoxedAppError {
330+
pub fn internal<S: ToString>(error: S) -> BoxedAppError {
331331
Box::new(InternalAppError {
332332
description: error.to_string(),
333333
})

0 commit comments

Comments
 (0)