当你遇到错误时,为什么 barista/coffeescript 不告诉你出了什么问题?

发布于 2024-11-07 13:49:33 字数 781 浏览 0 评论 0原文

我正在与咖啡师一起尝试 Coffeescript,但我使用起来并不愉快。

由于某种原因,每当我对 .coffee 文件进行更改时,咖啡师都会抱怨除了最微不足道的情况(例如对“警报”的简单调用)之外存在编译错误。

当我收到这些错误消息时,它实际上并没有告诉我出了什么问题 - 它只是说有一个“V8:JSError”。没有行号。没有什么。

为了修复这些错误,我按 CTRL-C Rails 服务器并重新启动它...一切都很好...但是对 .coffee 文件进行任何更改只会导致 Barista 抛出另一个编译器错误 - 并且该过程会重复。即使我添加正确的 Coffeescript 代码,它仍然会引发编译器错误。我不知道为什么。

怎么会有人这样编程呢?我需要良好的反馈,否则我会完全迷失。大多数时候,.coffee 文件不包含错误,因为它在我重新启动服务器后进行编译。

我也喜欢快速反馈,否则我会变得不耐烦。使用 Rails 进行开发的吸引力之一是一切都非常即时。不过,coffeescript 的事情肯定和 Java 中的工作一样糟糕。

尽管我讨厌 javascript,但至少反馈响应更快,而且我不必重新启动服务器。

难道是我刚才设置错了?这真的是用 CoffeeScript 编写代码的感觉吗?如果是……那么为什么在 Rails 3.1 中每个人都被迫这样做?

我只是今天过得不太好。如果结果很糟糕,我很抱歉。我已经花了几个小时使用咖啡脚本,但老实说我并没有取得多大进展。没有详细错误消息的编程以及被迫重新启动服务器才能看到我的更改生效让我想起了 Java...这就是我首先停止使用它的原因。

:(

I am trying out coffeescript with barista, and I am not having a good time with it.

For some reason, whenever I make a change to a .coffee file, barista complains that there is a compile error except for the most trivial of cases (like a simple call to 'alert').

When I get these error messages, it doesn't actually tell me what's wrong - it just says that there is a 'V8: JSError'. There are no line numbers. Nothing.

To fix these errors, I CTRL-C the Rails server and restart it... and all is well... but making any change at all to the .coffee file just causes Barista to throw yet another compiler error - and the process repeats. Even if I add correct Coffeescript code, it still throws a compiler error. I have no idea why.

How can anyone program like this? I need good feedback or I am totally lost. Most of the time, the .coffee file contains no error because it compiles after I restart the server.

I also prefer fast feedback, or I get impatient. One of the attractions to developing with rails is that everything is pretty immediate. This coffeescript thing though has to be as bad as working in Java.

As much as I hate javascript, at least the feedback is more responsive and I don't have to restart the server.

Did I just set this up wrong? Is this really what it's like to code in coffeescript? If it is... then why is this being forced on everyone in rails 3.1?

I'm just not having a good day today. I'm sorry if this comes off as bad. I've been spending hours with coffeescript and I honestly am not getting very far. Programming without detailed error messages and being forced to restart the server to see my changes take effect reminds me of Java... and that's why I stopped using it in the first place.

:(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凌乱心跳 2024-11-14 13:49:33

实际情况是,当 Barista 在 CoffeeScript 代码中遇到编译时错误时,它会获取该错误消息并将其用作 JS 输出。由于该错误消息是无效的 JS,因此您的浏览器会收到一个模糊的错误。如果您能想到更好的方法来做到这一点,您应该提出问题来提出建议。

现在,您应该做的是

  1. 查看页面的源代码,获取 JS 文件的地址,然后直接在浏览器中打开它,或者
  2. 使用文本编辑器的“构建”功能(例如 TextMate 中的 Cmd+B)显示相关 CoffeeScript 文件的编译输出或编译错误,或
  3. 使用 barista_growl 插件,以便当发生编译错误时,您会收到 Growl 通知。

以上都不是理想的,但浏览器对 CoffeeScript 调试的支持即将到来......

What's going on is that when Barista encounters a compile-time error in your CoffeeScript code, it takes that error message and uses it as the JS output. Since that error message is invalid JS, you get a vague error from your browser. If you can think of a better way to do this, you should raise an issue to suggest it.

For now, what you should do is either

  1. View the source of the page, get the address of the JS file, and open it up directly in your browser, or
  2. Use your text editor's “Build” feature (e.g. Cmd+B in TextMate) to show the compiled output, or compilation errors, of the responsible CoffeeScript file, or
  3. Use the barista_growl plugin so that you get a Growl notification when a compilation error occurs.

None of the above is ideal, but browser support for CoffeeScript debugging is coming...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文