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

feat: error handling #48

Merged
merged 14 commits into from
Oct 10, 2023
Merged

feat: error handling #48

merged 14 commits into from
Oct 10, 2023

Conversation

oskardotglobal
Copy link
Member

@oskardotglobal oskardotglobal commented Oct 7, 2023

All those .expects and nested match statements were bugging me, so I've written a custom error handler.

Basically, I've written 2 macros, which do the following:

  • unwrap_or_panic! & unwrap_or_exit! - Unwrap either an Option or a Result. Log the error of the result if it exists + further context with format! syntax support
  • error! & error_from! - Construct a WinappsError from an existing error and / or a message. This is mostly used to return values from functions, but you can still call panic and exit on it for the functionality of the 2 macros above

I've also documented all of them and all the structs, enums and traits I used.
This also includes the commits from #26, so that has to be merged first.

@oskardotglobal oskardotglobal added enhancement New feature or request rewrite Using the winapps rewrite priority: medium labels Oct 7, 2023
@oskardotglobal
Copy link
Member Author

This is ready for review now with #26 being merged

@LDprg
Copy link
Member

LDprg commented Oct 9, 2023

@oskardotglobal seems like something messed up with your repo, because it for example readds the quickemu installer script.

@oskardotglobal
Copy link
Member Author

Yeah, gotta merge first

@oskardotglobal
Copy link
Member Author

Ok, this is fully up-to-date now.

Copy link
Member

@LDprg LDprg left a comment

Choose a reason for hiding this comment

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

Some minor code parts did get lost, otherwise great work.

winapps/src/quickemu.rs Show resolved Hide resolved
winapps/src/quickemu.rs Show resolved Hide resolved
@oskardotglobal
Copy link
Member Author

Ok I've made some more changes; I've fully removed the unwrap_or_exit and unwrap_or_panic functions because them having the same name as the macros was kind of stupid because the IDE would automatically import those instead of the macros
I've replaced them with the into_error macro which just wraps the result in a function that does some type magic and returns a Result<T, WinappsError>. I've also documented all my changed

Copy link
Member

@LDprg LDprg left a comment

Choose a reason for hiding this comment

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

Almost finished.

winapps/src/quickemu.rs Show resolved Hide resolved
@oskardotglobal
Copy link
Member Author

there we go

Copy link
Member

@LDprg LDprg left a comment

Choose a reason for hiding this comment

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

This is now ready.

@LDprg LDprg merged commit eed3c31 into winapps-org:rewrite Oct 10, 2023
3 checks passed
@oskardotglobal oskardotglobal deleted the feat-errors branch October 28, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: medium rewrite Using the winapps rewrite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants