"Generator already running" message on any error - node.js

I have a very simple generator function, like this
exports.whatever = function *(next) {
this.body = 'wow';
z
};
Now, there obviously is a syntax error here ('z' on the third line),
but with koa's generators, the error I get in the console is basically useless for debugging; I do not get the line of the error, the file, or even the type of error. All I get is:
Error: Generator is already running
at GeneratorFunctionPrototype.next (native)
at onFulfilled (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:59:19)
at /Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:48:5
at Object.co (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:47:10)
at Object.toPromise (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:112:63)
at next (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:93:29)
at onRejected (/Users/johndoe/Documents/nodejs/testing/node_modules/koa/node_modules/co/index.js:79:7)
Is there any way to see the real detail of the error? Thanks in advance.

Related

AwesomeWM: Error when initialising a theme

I've currently started using the AwesomeWM and started configuring it. I struggle at theming: whenever I try to change the theme, I get this error message:
https://i.stack.imgur.com/vAbuW.png
It tells me that the error is on the line 553/554, but if I don't adjust any themes, they work without any errors.
Code for theming:
local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), "powerarrow")
beautiful.init(theme_path)
Lines the error says are wrong (553/554):
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
So, what's the problem?

How to catch errors (Smartsheet API Python SDK)

I am missing fundamental knowledge.
How to 'properly' catch errors returned by the API.
I'm using Python 3.+
If I pass in the wrong sheet ID
try:
update_sht = SmSh.Sheets.get_sheet(dd_id)
print("OK?:", update_sht, flush=True)
except:
print("Error Print:\n", update_sht)
I get this response (in the IPython console)
Response: {
status: 404 Not Found
content: {
{
"errorCode": 1006,
"message": "Not Found",
"refId": "jod4cgoou0sw"
}
}
OK?: {"result": {"code": 1006, "errorCode": 1006, "message": "Not Found",
"name": "ApiError", "recommendation": "Do not retry without fixing the
problem. ", "refId": "jod4cgoou0sw", "shouldRetry": false,
"statusCode": 404}}
and while it returns an error response, it isn't an exception according to try/except.
At this point, I would like to exit out of the loop I am in, instead of continuing on until I get to other lines of code like this
for col in update_sht.columns:
that DO give errors that cause the program to fail.
Traceback (most recent call last):
File "<ipython-input-195-85dde6ec7071>", line 1, in <module>
xxx(debug=False)
File "<ipython-input-194-0b889c817b08>", line 75, in xxx
for col in update_sht.columns:
AttributeError: 'Error' object has no attribute 'columns'
I'm doing more than one thing on the sheet, if I find it, and would prefer not to have a try/except around error line of code (I exaggerate) unless I need them for other errors.
I know/hope this is easier than I have been trying to make it, but as I opened with, I am missing something fundamental.
-Craig
---- UPDATE ----
I am going around in circles.
If errors_as_exceptions is true, then this
update_sht = SmSh.Sheets.get_sheet(dd_id)
raises and exception, but
print(update_sht)
or anything similar shows the previous good value in the object.
How do I determine the status code and error codes so I can take appropriate action?
Nothing I have tried has worked.
If errors_as_exceptions is false, then this
update_sht = SmSh.Sheets.get_sheet(dd_id)
print(update_sht.result.code)
gives me the error code, but only when there is an error ... so I need to catch the error that occurs when there is no
error.
If I raise the error (errors_as_exceptions=True), how do I determine the status code and error code and if I don't raise the error,
how do I do the same?
I want to prevent my code from failing and give the user useful information on what needs to be fixed.
If you set ss.errors_as_exceptions() and your code looks something like this
try:
my_sheet = ss.Sheets.get_sheet(sheet_ID)
print(my_sheet)
except Exception as e:
print(e.message)
The result will look something like this 1006: Not Found. So, the exception message appears to be errorCode:message.
If you want the Python SDK to raise exceptions for API errors call the errors_as_exceptions method on the client object, e.g.
ss = smartsheet.Smartsheet()
ss.errors_as_exceptions()

Invalid Syntax for PEP-8

I'm receiving a notification that advised the below script is not PEP-8:
example_var = print('whoa')
Output:
[E] invalid syntax.
It's showing that the error is a result of the first parentheses in the print statement, but nothing looks off to me.
example_var = print('whoa')
example_var

Set function return type in Haxe

For some reason, I get this error message whenever I try to compile this simple function: Test.hx:1: lines 1-7 : Invalid -main : Test has invalid main function
public static function main(a:Int, b:Int){
trace("Calling main function");
return a+b;
}
I'm not sure why this is happening. What's wrong with this function definition, and how can I get it to compile correctly? I tried reading the documentation, and found it to be unclear in its explanation of how to properly set function return types.
The special main entry function must be a Void->Void function. i.e. No param and no return value is allowed. Remember there is no command line argument concept in JS/Flash, which Haxe also compiles to. So we have to use system targets' API for that:
Sys.args() : Array<String> to get the command line params.
Sys.exit( code : Int ) : Void to exit with exit code.
FYI, the doc of Sys is at http://haxe.org/api/sys

How to solve "callback not fired" with Vows and Node.js

I'm trying to get started with Vows and Vows-BDD. Unfortunately, the callbacks are tripping me up.
In the very simple example below, how does one fix this error?
** Inside the first context
** Creating Person with name Nick
✗ Errored » callback not fired
in Create a Person via JavaScript: When a person has a name,
in Creating a Person
in undefined✗ Errored » 1 errored 1 dropped
vows_bdd = require "vows-bdd"
assert = require "assert"
class Person
constructor: (#name) ->
console.log "** Creating Person with name #{#name}"
greeting: ->
"Hello, #{#name}"
vows_bdd
.Feature("Creating a Person")
.scenario("Create a Person via JavaScript")
.when "a person has a name", ->
console.log "** Inside the first context"
new Person "Nick"
.then "the person can be greeted", (person) ->
console.log "person is a #{typeof person} = [#{person}]"
assert.equal person.greeting(), "Hello, Nick"
.complete()
.finish(module)
I know this post is old, but as this is the first result when someone searches for this error, I am posting my answer.
I found this post helpful, when dealing with error.
http://birkett.no/blog/2013/05/01/vows-errored-callback-not-fired/.
In my code error was due to an exception occurring in one of the topics. Vows does not print actual error, because of that its difficult to understand exact problem.

Resources