Add better error messages when Outfit construction fails.#110
Open
Kasekopf wants to merge 9 commits intoloathers:mainfrom
Open
Add better error messages when Outfit construction fails.#110Kasekopf wants to merge 9 commits intoloathers:mainfrom
Kasekopf wants to merge 9 commits intoloathers:mainfrom
Conversation
src/outfit.ts
Outdated
| }; | ||
| } | ||
|
|
||
| const SUCCESS: EquipResult = { success: true }; |
Contributor
There was a problem hiding this comment.
This being mutable and reused leads to an extremely, extremely funny failure case
Contributor
There was a problem hiding this comment.
In particular, because the SUCCESS object itself gets returned, it can cause a problem.
src/outfit.ts
Outdated
| function mergeResults(results: EquipResult[]) { | ||
| const failures = results.filter((r) => !r.success) as { reason: string }[]; | ||
| if (failures.length === 0) return SUCCESS; | ||
| return fail(failures.map((r) => r.reason).join(" ")); |
Contributor
There was a problem hiding this comment.
I'm not sure how I feel about a space as the delimiter
Contributor
|
I recognize I'm commenting on a PR that's been open for a year but it would be nice to be able to toggle verbosity globally rather than based on which methods you call, ideally using libram's log levels or something similar. Would tie in nicely with #111 |
Contributor
|
This would be a very nice addition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
outfit.equipVerbosewhich either succeeds in equipping a thing or returns a string error message. This allows forforceEquipwhich throws the message as an error.Internally, all the private subfunctions to modify the outfit have been changed to also return a string error message on failure.