Custom Arg - ResultError Unwrap failed
This seemed to be working for me in a previous version of Sapphire - but I've only recently gotten back into the swing of things, so there's a good chance I've missed a change.
I have a prefix command that has a single arg. The custom arg works great, for returning a result where a result actually does exist (items from item system)
Where that item doesn't exist, it throws an error with the identifier "InputNotanItem".
When this was working - the first
.catch
only returned null
(which is also a valid response). I've added this catch to try and catch something earlier than my outer try/catch, in case there's some issue there.
I can see that the err
does include identifier
and parameter
, but I cannot read these values - I'm assuming it has something to do with this..
ResultError: UnwrapFailed
Solution:Jump to solution
After PR 601 (https://github.com/sapphiredev/framework/pull/601) is merged and released then the
err.value
is no longer needed.25 Replies
Command (messageRun)
DrpgItemArg
I've come across this issue and PR, but I'm not understanding the solution/new approach in
sapphiredev/utilities#475
https://github.com/sapphiredev/framework/issues/528
https://github.com/sapphiredev/utilities/pull/475I can help like near the end of the afternoon (9ish hours) so if anyone from @Helpers can help that'd be great.
A few general notes:
1. It would help if you provide a minimal reproduction repository
2. Make sure to dedupe your dependencies. We've had some people having troubles with multiple versions of result.
That's because err is an unwrapped error, not ArgumentError
could you please elaborate? what/how did this change, I'm not sure how to handle the error properly now
okay thanks - I'll see what I can do. If I haven't got anywhere in the next hour or two with it - this might take me a few days to pull together - holiday festivities and all
console log the error to find out what instance it actually is. im not sure from the top of my head either.
(it should be ArgumentError still but it might not be unwrapped, contrary to what Kyra said. And if it's not an ArgumentError but another class then it might be a bug in the sapphire code (wouldnt be the first time Kyra wrote something with Result / arg parsing that is actually broken and because Skyra never updated to Framework v3 she tends to be completely oblivious to the bugs it had/has))
that's exactly what the message in the OP is - the result of
console.log(err)
Which... I don't understand, because it doesn't quite look like an object
the last ~4 lines do look like an object... and it does mention the value
too, about mid-way through the log
value - is using the message
as provided in my return Args.error({...
ugh well I can't help much more rn. Im about to leave also.
no worries - appreciate you taking a look - happy holidays 🙂
Why is there asynchronous code mixed with synchronous code and is there that asynchronous code inside a trycatch that will never work because the asynchronous code has a .catch?
Or were you just testing?
Ah, the async inside of the then was left over from testing/trying to fix. Same behaviour with or without it
The matching of the arg itself is async
It otherwise works as expected, catching, throwing, other than reading the properties off the err
If you can make a small repro repo after the holidays that'd be great so we can have a proper look at the issue
Do you want me to open an Issue on GitHub for it, or just provide the link here?
@Helpers as requested - repro repo can be found here
https://github.com/Bejasc/repro-sapphire-unwrap-error
GitHub
GitHub - Bejasc/repro-sapphire-unwrap-error
Contribute to Bejasc/repro-sapphire-unwrap-error development by creating an account on GitHub.
Nice
Hey @Favna - have you had a chance to check out the repro?
I havent
@Helpers hey folks - wondering if anyone has had a chance to check out the repro above and has any thoughts/ideas they could offer me?
im looking now
@Bejasc
This fixes the code. Specifically,
err.value
instead of err
. Also typed here to show what the actual type was.Here are all the changes I made. It might just be because you were making the repro but you should mind some of the other changes applied as well such as line 40 in
Test.ts
Also the way excludes
for tsconfig works is that it excludes that what was previously included with includes
. So excluding node_modules
is only relevant if there is src/node_modules
.
https://github.com/favna/repro-sapphire-unwrap-error/commit/f197a3b490106e38fbf839f808bd56ffc9040718
(you probably want to click "no whitespace" at the top before looking because I also ran Prettier)Haven't got around to trying this out yet sorry - will let you know when I have
Solution
After PR 601 (https://github.com/sapphiredev/framework/pull/601) is merged and released then the
err.value
is no longer needed.Thanks so much for remembering this and getting back to me. Ace support 💯
You can thank @Vladdy for reminding me of issue 528