Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Calling render without file or data produces a cryptic error message #924

Closed
callumlocke opened this issue May 5, 2015 · 14 comments
Closed

Comments

@callumlocke
Copy link

On master, and doing sass.render({contents: input}, callback).

When input is an empty string, I get the error File context created without an input path.

@xzyfer
Copy link
Contributor

xzyfer commented May 5, 2015

Hi @callumlocke, node-sass@3.x (master) doesn't support contents as an option. You will need to use either file or data for file paths for file data respectively.

We should provide a more informative error message.

@callumlocke
Copy link
Author

But contents works fine for me. (Just not with an empty string.)

@xzyfer
Copy link
Contributor

xzyfer commented May 5, 2015

Interesting... can you please supply an example of how you're using node-sass with contents?

@callumlocke
Copy link
Author

No wait, maybe I am using data not contents. Not at a computer right now. I probably just entered the issue wrong. Sorry for confusion.

The point is, whatever property name I'm using, it works fine - except for when the value is an empty string, in which case I get the obscure error message.

@xzyfer
Copy link
Contributor

xzyfer commented May 5, 2015

Thanks for the clarification, I do think we need a better error message in this case.

@xzyfer xzyfer changed the title "File context created without an input path" Calling render without file or data produces a cryptic error message May 5, 2015
@xzyfer xzyfer self-assigned this May 5, 2015
@saper
Copy link
Member

saper commented May 5, 2015

Empty braces cause this as well:

var sass = require('node-sass');

sass.render({
}, function(err, result) {
   if (err) {
        console.error(err);
   } else {
        console.log('successfully rendered');
   }
});

https://gist.github.com/95b3f79c73c0ab2a0a09

@callumlocke
Copy link
Author

So there's two separate problems:

  1. Cryptic error message if you fail to provide either file or data (i.e. if both are undefined).
  2. If data is an empty string, node-sass behaves as if it's undefined, and errors out. An empty string is valid Sass so it should not error. Should I open this as a separate issue?

@saper
Copy link
Member

saper commented May 5, 2015

No, no need to, thanks. This is actually the same issue.

@saper
Copy link
Member

saper commented May 13, 2015

Should be fixed by #956. Now I think that the behaviour with render({}) is acceptable - we can complain either about data or file context; we don't know which one was really meant.

@callumlocke
Copy link
Author

It still errors out for me if I try to render/import a file that happens to be empty.

@xzyfer
Copy link
Contributor

xzyfer commented Jun 29, 2015

@callumlocke the patch has not yet been merged. It'll be in the next release of node-sass.

@saper
Copy link
Member

saper commented Aug 20, 2015

Would No input specified: provide options.data or options.file be a better error message?

I also wonder what we should do in case of async functions: show we call a callback and emulate a libsass error JSON object?

saper added a commit to saper/node-sass that referenced this issue Aug 20, 2015
saper added a commit to saper/node-sass that referenced this issue Aug 21, 2015
@saper
Copy link
Member

saper commented Aug 21, 2015

#956 should be ready for testing.

saper added a commit to saper/node-sass that referenced this issue Aug 21, 2015
saper added a commit to saper/node-sass that referenced this issue Aug 23, 2015
@xzyfer
Copy link
Contributor

xzyfer commented Aug 24, 2015

Would No input specified: provide options.data or options.file be a better error message?

Yes. It's exponentially better.

I also wonder what we should do in case of async functions

You suggestion sounds legit.

@saper saper added this to the next.minor milestone Aug 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants