Skip to content

Handling failure cases #2

@Anaminus

Description

@Anaminus

Roblox appears to have at least three kinds behaviors when a parsing failure occurs:

Hard

Parsing halts completely. An error message is usually displayed.

Default

Failing to parse a property results in a default value that is dependent on the property. Parsing continues as normal.

Example: Part.CanCollide, a bool, defaults to true. If parsing fails, the result is true. BoolValue.Value defaults to false. If parsing fails, then the result is false.

Zero

Failing to parse a property results in a value that is the "zero" or initialized value for the type. Parsing continues as normal.

Example: Part.Color, a Color3, defaults to 163, 162, 165. If parsing fails, then the result is 0, 0, 0.

Representation

A hard-failure is represented by an error struct. The content of the golden error message doesn't matter much as long as it's distinct, and the program is able to detect the error and transform it into the expected message.

Default-failures are difficult to get exactly right, because it requires additional metadata which is not readily available, and so may not be supported by 3rd-party implementations. This could be resolved by discarding the property entirely, which retains the distinction from zero-failures:

Failure Input Golden
Zero some value different, but expected value
Default some value no value at all

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions