I must be losing it. This class gives an error stating 'Syntax error at '}' on the last line of the file when running puppet agent. Am I missing a brace or other obvious issue?
class roles::webserver::na {
class { 'profiles::webserver::ourwebserver':
market => 'na'
}
Class['profiles::webserver::ourwebserver']
}
..not sure if it helps diagnose, but ourwebserver starts out like so:
class profiles::webserver::ourwebserver($market) {
...
Looks like the problem was with the Class['profiles::webserver::ourwebserver'] bit, apparently with only one class the ordering statement above isn't needed.
Related
I have problems to understand the syntax with which pages are described (defined) in Geb. The following is an example page class that works fine but I don't understand how it works.
import geb.Page
class GebHomePage extends Page{
static url = "http://gebish.org"
static at = { title == "Geb - Very Groovy Browser Automation" }
static content = {
seeGuideButton { $('div', class:'ui huge primary button') }
uiHeader { $('h1', class:'ui header', 0)}
}
}
I am interested in the syntax inside the closure referred to by content. Geb describes the syntax for the content DSL as
«name»(«options map») { «definition» }
I don't understand this syntax. The name part looks like a variable, but it is not declared (I miss a def or something similar) and the last part looks like a closure. But where is the connection between the name and the closure. There is no equal sign connecting the two. In a standard groovy class the syntax
«name» { «definition» }
does not compile. What happens in one line of the content DSL? What precisely are uiHeader and seeGuideButton and how are they related to the following closures? How does this syntax work exactly?
Behind the scenes, Geb looks for a method with the signature:
uiHeader(Map, Closure)
In groovy, you can catch when a method is missing (see methodMissing) so internally Geb will catch this and know how to resolve any future requests for that variable
Also in groovy, a Closure as the last parameter can be outside the brackets, which is why you can do
uiHeader(required: false) { $('h1') }
I am using TypeScript 2.0 in VSCode, however, the errors highlighted are all confirmed by the TypeScript compiler. So I am importing a module:
import * as els from 'elasticsearch';
where elasticsearch has definitions installed, e.g. npm i #types/elasticsearch -S
Now if in my class I have a property with an els type like this:
private _client: els.Client;
There isn't an issue, however, if I have a property with a type like this:
search(term: string): Promise<els.Client.search> {}
then I get the error:
Module 'Elasticsearch' has no exported member 'Client'
How can the class not be found if I'm looking for one of its properties, but not if I just look for it?
You are right, the error message is confusing. It originates from your attempt to use els.Client.search as a type. You get similar messages if you try this:
import * as els from 'elasticsearch';
class Foo {
private _client: els.Client;
y: els.Client.search;
bar() {}
x: Foo.bar;
}
error TS2305: Module 'Elasticsearch' has no exported member 'Client'.
error TS2503: Cannot find namespace 'Foo'.
Note how in the second message it complains that it can't find Foo right within the Foo class. You might consider posting an issue for typescript about this.
How can the class not be found if I'm looking for one of its
properties, but not if I just look for it?
The real problem is that you probably want the return type of your search to be the same as the return type of els.Client.search. I don't think there is a better way to do that other than essentially copy els.Client.search declaration:
search<T>(term: string): Promise<els.SearchResponse<T>> {}
I have a DoFixture in the package be.acred.b2c.ws.creditRequest.service.MyFixture
When I run a test using Fitnesse I get the following error message.
Missing method: public TypeOfResult
getBeDotAcredDotB2cDotWsDotCreditRequestDotServiceDotMyFixture() { }
OR: public TypeOfResult
beDotAcredDotB2cDotWsDotCreditRequestDotServiceDotMyFixturee() { }
in class be.acred.b2c.ws.creditRequest.service.MyFixture
I can see that I'm not the only one having that problem but I can't find a solution on the Web.
Ok, I could as well define that method in my fixture, but I'd like to understand why it's there and if there is any cleaner way to get rid of that error.
Any help would be greatly appreciated.
Here's the page code. The same structure works fine when I'm using a ColumnFixture instead of a DoFixture.
!*> Classpath
!pomFile C:\Users\otonglet\WORKSPACES\b2c\pom.xml#test
*!
!|be.acred.b2c.ws.creditRequest.service.MyFixture|
|init_request|1250.00|
|form_data|{some json data}|language|en_us|
|send_request|en_us|
|show|key|
I just received an exception when I try to reference a static variable in another class, which is also statically initialized. This worked before, and for some reason it fails now. The only changes I made were resetting Visual Studio (2010) to its default setting, which I can't imagine to be the reason for this. Any other code I added didn't touch any of the affected parts either.
This is my code
WinForms class 'MainForm':
partial class MainForm : Form
{
// ...
private RefClass convMan;
private Dictionary<EnumType, string> LogNames = RefClass.LogNames;
// ...
public MainForm() { .... }
}
Referenced class 'RefClass':
class RefClass
{
// ...
public enum EnumType { TypeOne = 0, TypeTwo = 1, TypeThree = 2 };
public static Dictionary<EnumType, string> LogNames = new Dictionary<EnumType, string>()
{
{ EnumType.TypeOne, "Text0" },
{ EnumType.TypeTwo, "Text1" },
{ EnumTypy.TypeThree, "Text2" }
};
}
The error I get now is (translated from German):
An unhandled exception of type "System.TypeInitializationException" occurred.
Additional information: The type initializer for "RefClass" threw an exception.
which has the InnerException
System.ArgumentException
So, as far as I'm concerned, my static dictionary should be initialized once it gets accessed, thus when my Form class references it. I tried debugging to see if the static dictionary is initialized before it gets referenced in the Form class, which is not the case. Also, when I stop at a breakpoint for the reference line, the variable LogNames is null.
I'm really confused as to why this happens, it all worked before.
I found my error, the exceptions I got were quite misleading though. It was a problem with a different dictionary than the one I referenced. It probably didn't get initialized in the first place because something before that failed (If someone can clear this up, please feel free to do so!). Basically what I did wrong was using a two-directional dictionary and adding a value twice. This should normally produce a normal exception, but since it was done statically it got wrapped into a TypeInitializationException. I had a deeper look into the exact stacktrace of the inner exception and found where the exception originated from. Maybe this helps someone in the future...
I had a simular issue getting the same exception. Found that my static constructor for my utility class was generating the exception. Took some time locating since the description of the exception was misleading.
As #Yeehaw mentioned, it appears that the exception gets wrapped, so the common denominator here I would say is that the class/object is static.
I am running into a problem when trying to implicitly convert one of my dynamic types. There are two assemblies with definitions similar to the following:
Configuration.dll:
public class ConfigurationValue : DynamicObject
{
public ConfigurationValue(string val)
{
//...
}
//...
public static implicit operator string(ConfigurationValue val)
{
return val.ToString();
}
}
There is another class in this dll called Configuration with a member variable called Instance (to make the class singleton). This variable holds the ConfigurationValue instances in a dictionary and is of type dynamic. This allows me to do this following:
Server.dll:
//...
if (Configuration.Instance.SecurityLevel != "Insecure")
{
//...
}
Assuming that SecurityLevel is in the dictionary.
This if statement appears verbatim in my code and always fails with the following error:
{"Operator '!=' cannot be applied to operands of type 'System.Dynamic.DynamicObject' and 'string'"}
Previously, when these two classes were in the same assembly, this code worked fine. Can anyone tell me what I'm doing wrong here?
Thanks,
Max
Solved the problem, a little embarrassing actually, I forgot to change the container class for ConfigurationValue (e.g. the type of Configuration.Instance) from internal to public when I moved it to the new assembly, so of course the type couldn't be resolved and the implicit conversion was not found
Try
var SecurityLevel = new ConfigurationValue("Insecure");