-
Notifications
You must be signed in to change notification settings - Fork 19
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: improve error types and messages by using thiserror
#600
Conversation
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
…t tests Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
…ypescript, and java Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
c7d4cca
to
692696e
Compare
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Signed-off-by: Francis <colifran@amazon.com>
Codecov Report
Additional details and impacted files
@@ Coverage Diff @@
## main #600 +/- ##
=======================================
+ Coverage 82.1% 86.3% +4.2%
=======================================
Files 27 27
Lines 5097 5212 +115
Branches 5097 5212 +115
=======================================
+ Hits 4186 4499 +313
+ Misses 741 468 -273
- Partials 170 245 +75
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
This PR introduces an improved mechanism for defining error types and associated error messages throughout the source code via the
thiserror
crate.Previously, a single error named
TransmuteError
was defined. This error was implemented manually by implementingTransmuteError
,From for TransmuteError
, andDisplay for TransmuteError
.TransmuteError
was all encompassing for any transmutation related errors such as resource translation errors, parsing errors, import instruction errors, etc. Additionally, any use of thepanic!
,unimplemented!
, orunreachable!
macro will result in an error message that says "unreachable" in wasm assemblies.In general, our current mechanism for defining error types and messages causes several problems:
panic!
,unimplemented!
, orunreachable!
macrosUsing the
thiserror
crate will eliminate these problems by allowing us to quickly define new error types that can be appropriately scoped by simply adding to theError
enum. The manual work of implementing new custom error types will be handled by thethiserror
crate. Additionally, we can migrate away from thepanic!
,unimplemented!
, orunreachable!
macros to provide a better UX with improved error details.In addition to the changes outlined above, this PR fixes 5 bugs found:
!
instead ofnot
forCondition::Not
!
applied to the first operand forCondition::Not
rather than applying!
to the entire statement wrapped in parentheses. This produces an error because!
is only valid for booleans, but applying!
to the first operand will result in instances where!
is applied to a string or numberCondition::And
Condition::Not
values to snake caseThis PR refactored several areas in the csharp synthesizer that were not testable. The first area is the
ResourceIr::Object
arm when matching againstResourceIr
. This branch had the same error case in multiple branches when matching against theResourceIr::Object
structure. As a result, only the first error could be tested for. A more correct implementation would be to factor this invalid structure out into a single arm that will throw an error if encountered.Additionally,
ConditionIr
was implementingCsharpEmitter
; however, this is no longer correct becauseConditionIr
does not throw any errors. This meant that the error case in eachConditionIr
branch was unable to be tested.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.