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

terminate called after throwing an instance of 'std::ios_base::failure' #49

Closed
loverszhaokai opened this issue May 2, 2015 · 1 comment

Comments

@loverszhaokai
Copy link
Contributor

$ ls folder
input.jsonnet
$ cat folder/input.jsonnet

import "" {
    cocktails +: {
        "Whiskey Sour": {
            ingredients: [
                { kind: "Scotch", qty: 1.5 },
                { kind: "Lemon Juice", qty: 0.75 },
            ],
            garnish: "Lemon Peel",
            served: "On The Rocks",
        }
    }
}

$ ../jsonnet folder/input.jsonnet
terminate called after throwing an instance of 'std::ios_base::failure'
what(): basic_filebuf::underflow error reading the file
Aborted

@sparkprime
Copy link
Collaborator

Good catch. I'm adding explicit checks for importing the empty strings and directories. But you can still import "." which I can't detect is a directory in standard C++. So I'll just turn the IO error into a Jsonnet runtime error:

$ jsonnet -e 'import ""'
RUNTIME ERROR: Couldn't open import "": The empty string is not a valid filename
:1:1-9
$ jsonnet -e 'import "."'
RUNTIME ERROR: Couldn't open import ".": basic_filebuf::underflow error reading the file
:1:1-10
$ jsonnet -e 'import "/"'
RUNTIME ERROR: Couldn't open import "/": Attempted to import a directory
:1:1-10

Hopefully that's good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants