Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Enhanced parser / redmine error-handling #152

Merged
merged 4 commits into from
Dec 21, 2024
Merged

Conversation

m1sk9
Copy link
Member

@m1sk9 m1sk9 commented Dec 21, 2024

SSIA

@m1sk9 m1sk9 enabled auto-merge (squash) December 21, 2024 13:56
@m1sk9 m1sk9 changed the title refactor: Enhanced parser error-handling refactor: Enhanced parser / redmine error-handling Dec 21, 2024
@m1sk9 m1sk9 merged commit 4f6ceb9 into main Dec 21, 2024
1 check passed
@m1sk9 m1sk9 deleted the add-error-handing branch December 21, 2024 14:28
Copy link
Member

@KisaragiEffective KisaragiEffective left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あとで改善したいところ

Comment on lines +32 to +35
if message.embeds.first().is_none() {
return;
};
let embed = match parse_embed(message.embeds.first().unwrap()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if message.embeds.first().is_none() {
return;
};
let embed = match parse_embed(message.embeds.first().unwrap()) {
let Some(first_embed) = message.embeds.first else { return; };
let embed = match parse_embed(first_embed) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let Some(...) そんな記法あったの

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let-elseでググると良い

}

fn parse_issue_number(title: &String) -> anyhow::Result<u16, ParseEnvIDsError> {
let re = match regex::Regex::new(r"#(\d+)") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

毎回Regexの構築が走って無駄なので https://doc.rust-lang.org/std/cell/struct.LazyCell.html で持ちたい

src/parsers.rs Show resolved Hide resolved
Comment on lines +68 to +71
Some(caps) => match caps.get(1).unwrap().as_str().parse::<u16>() {
Ok(num) => Ok(num),
Err(why) => Err(ParseEnvIDsError::FailedToParseIssueNumber(why.to_string())),
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic-safeにするなら気持ち的にはget(1).unwrap()をやめたくない?という気持ちがある。
そうではなくてもunwrapではなくexpectにしたいところ

src/parsers.rs Show resolved Hide resolved
src/parsers.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants