如何在Java 8中使lambda函数报告失败?
我在Node.js中看到这是可能的.
http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
使用回调参数
Node.js运行时v4.3支持可选的回调参数.您可以使用它将信息显式返回给调用者.一般语法是:
callback(Error error, Object result);哪里:
error - 是一个可选参数,可用于提供失败的Lambda函数执行的结果.当Lambda函数>成功时,您可以传递null作为第一个参数.
result - 是一个可选参数,可用于提供成功执行函数的结果.提供的结果必须与JSON.stringify兼容.如果提供了错误,则忽略此参数.
注意
使用回调参数是可选的.如果不使用可选的回调参数,则行为与调用不带任何参数的callback()相同.您可以在代码中指定回调以将信息返回给调用者.
如果您不在代码中使用回调,AWS Lambda将隐式调用它,返回值为null.
当调用回调(显式或隐式)时,AWS Lambda继续Lambda函数调用,直到Node.js事件循环为空.
以下是示例回调:
callback(); // Indicates success but no information returned tothe caller. callback(null); // Indicates success but no informationreturned to the caller. callback(null, "success"); // Indicatessuccess with information returned to the caller. callback(error);
// Indicates error with error information returned to the caller.AWS Lambda将error参数的任何非null值视为已处理的异常.
我是一名VB开发人员,目前正在破译用C#编写的应用程序.一般来说,我可以通过谷歌找到答案.但我迷失了.C#中使用的波浪号(〜)是多少?
这是一个包含表达式的剪辑:
/// <summary>
/// Updates the window style for the parent form.
/// </summary>
private void UpdateStyle()
{
// remove the border style
Int32 currentStyle = Win32Api.GetWindowLong(Handle, GWLIndex.GWL_STYLE);
if ((currentStyle & (int)(WindowStyles.WS_BORDER)) != 0)
{
currentStyle &= ~(int) (WindowStyles.WS_BORDER);
Win32Api.SetWindowLong(_parentForm.Handle, GWLIndex.GWL_STYLE, currentStyle);
Win32Api.SetWindowPos(_parentForm.Handle, (IntPtr) 0, -1, -1, -1, -1,
(int) (SWPFlags.SWP_NOZORDER | SWPFlags.SWP_NOSIZE | SWPFlags.SWP_NOMOVE |
SWPFlags.SWP_FRAMECHANGED | SWPFlags.SWP_NOREDRAW | SWPFlags.SWP_NOACTIVATE));
}
}
Run Code Online (Sandbox Code Playgroud)