Skip to content
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

Better error reporting #17

Open
kubkon opened this issue Nov 22, 2022 · 0 comments
Open

Better error reporting #17

kubkon opened this issue Nov 22, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@kubkon
Copy link
Owner

kubkon commented Nov 22, 2022

Our error reporting capabilities are restricted to a bare Zig error. For example, the following malformed YAML

key1:
  key1_1: value1_1:
  key1_2: value1_2
key2: value2
key3:
  key3_1: value3_1
  key3_2: value3_2
  key3_3: value3_3

generates the following error and an error trace (in debug and release safety build modes)

error: MalformedYaml                                                                                                                                                                                                                                                                                                           
/home/kubkon/dev/zig-yaml/src/parse.zig:475:21: 0x26dce8 in map (yaml)                                                                                                                                                                                                                                                         
                    return error.MalformedYaml;                                                                                                                                                                                                                                                                                
                    ^                                                                                                                                                                                                                                                                                                          
/home/kubkon/dev/zig-yaml/src/parse.zig:339:17: 0x2463bb in value (yaml)                                                                                                                                                                                                                                                       
                return self.map();
                ^
/home/kubkon/dev/zig-yaml/src/parse.zig:467:25: 0x26da5f in map (yaml)
            const val = try self.value();
                        ^
/home/kubkon/dev/zig-yaml/src/parse.zig:339:17: 0x2463bb in value (yaml)
                return self.map();
                ^
/home/kubkon/dev/zig-yaml/src/parse.zig:467:25: 0x26da5f in map (yaml)
            const val = try self.value();
                        ^
/home/kubkon/dev/zig-yaml/src/parse.zig:339:17: 0x2463bb in value (yaml)
                return self.map();
                ^
/home/kubkon/dev/zig-yaml/src/parse.zig:383:22: 0x23bd90 in doc (yaml)
        node.value = try self.value();
                     ^
/home/kubkon/dev/zig-yaml/src/parse.zig:313:33: 0x23a06e in parse (yaml)
                    const doc = try parser.doc();
                                ^
/home/kubkon/dev/zig-yaml/src/yaml.zig:229:9: 0x23c634 in load (yaml)
        try tree.parse(source);
        ^
/home/kubkon/dev/zig-yaml/examples/yaml.zig:95:18: 0x23f791 in main (yaml)
    var parsed = try yaml.Yaml.load(allocator, source);

The library is in dire need of some actual error reporting mechanism that would bubble up any errors and produce a printout where such an error occurred in the input source stream, etc.

@kubkon kubkon added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant