小编tec*_*man的帖子

如何指定HTTP错误代码?

我试过了:

app.get('/', function(req, res, next) {
    var e = new Error('error message');
    e.status = 400;
    next(e);
});
Run Code Online (Sandbox Code Playgroud)

和:

app.get('/', function(req, res, next) {
    res.statusCode = 400;
    var e = new Error('error message');
    next(e);
});
Run Code Online (Sandbox Code Playgroud)

但总是宣布错误代码为500.

http-status-codes node.js express

143
推荐指数
10
解决办法
19万
查看次数

process.getuid()无法在Windows上运行

我创建了一个只包含一行代码的脚本:

console.log('userid: ' + process.getuid());
Run Code Online (Sandbox Code Playgroud)

当我使用该命令运行脚本时node filename.js,会发生以下错误:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick  
^  
TypeError: Object #<EventEmitter> has no method 'getuid'  
at Object.<anonymous> (c:\PROGRA~1\nodejs\node_modules\mrt\p.js:1:96)  
at Module._compile (module.js:441:26)  
at Object..js (module.js:459:10)  
at Module.load (module.js:348:31)  
at Function._load (module.js:308:12)  
at Array.0 (module.js:479:10)  
at EventEmitter._tickCallback (node.js:192:40)
Run Code Online (Sandbox Code Playgroud)

我正在Windows上运行node.js.

javascript node.js

6
推荐指数
1
解决办法
5524
查看次数

构建Linq表达式

我可以轻松地构建任何linq表达式而无需使用Expression工厂方法.例如:

Func<int, string> f = i =>
{
    var result = i.ToString();
    //... rest of the code
    return result;
};

Expression<Func<string>> f2 = () => f(123);
var s = f2.Compile()();
Run Code Online (Sandbox Code Playgroud)

通过调用工厂方法手动构建表达式有什么好处?

c# linq

1
推荐指数
1
解决办法
174
查看次数

标签 统计

node.js ×2

c# ×1

express ×1

http-status-codes ×1

javascript ×1

linq ×1