-
Notifications
You must be signed in to change notification settings - Fork 359
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
Error handling experiment #5429
Conversation
+10 TerriaBucks for writing docs 🌟 |
…lean up error messages
*/ | ||
export default class Result<T> { | ||
/** Convenience function to return a Result with an error */ | ||
static error(error: TerriaErrorOptions | TerriaError): Result<undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting choice to require the T
type to include undefined
(so that Result.error
is assignable). I haven't thought through all of the implications of that yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T
doesn't have to include undefined
. It just is undefined
if you use the Result.error
convenience constructor thing
lib/Core/Result.ts
Outdated
private readonly value: T, | ||
private readonly error?: TerriaError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like there to be some way to differentiate between a recoverable error and a non-recoverable error, unless you think that shouldn't be one of the aims of the Result type. Is that expressed outside the definition of the Result class using undefined
as a value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that could totally be apart of the Result
or TerriaError
class - I just left it out as I didn't find any need in the "initial loading" stuff in Terria.ts
.
I figured we could add it wherever when it's needed
@@ -825,48 +842,74 @@ export default class Terria { | |||
} | |||
); | |||
|
|||
const errors: TerriaError[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bookmark
Co-authored-by: Emma Krantz <3796838+KeyboardSounds@users.noreply.github.com>
I applied this to |
Apply new Result/TerriaError pattern to traits.fromJson()
Just waiting on the |
First pass at improving error handling (mostly in
Terria.ts
)Related to #3486
This will need changes in TerriaMap - TerriaJS/TerriaMap#526
Checklist