Custom error class in TypeScript

TypeScript 2.1 had a breaking changes regarding Extending built-ins like Error. From the TypeScript breaking changes documentation class FooError extends Error { constructor(msg: string) { super(msg); // Set the prototype explicitly. Object.setPrototypeOf(this, FooError.prototype); } sayHello() { return “hello ” + this.message; } } Then you can use: let error = new FooError(“Something really bad went … Read more

Abstract classes in Swift Language

There are no abstract classes in Swift (just like Objective-C). Your best bet is going to be to use a Protocol, which is like a Java Interface. With Swift 2.0, you can then add method implementations and calculated property implementations using protocol extensions. Your only restrictions are that you can’t provide member variables or constants … Read more

Maven project version inheritance – do I have to specify the parent version?

Since Maven 3.5.0 you can use the ${revision} placeholder for that. The use is documented here: Maven CI Friendly Versions. In short the parent pom looks like this (quoted from the Apache documentation): <project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache</groupId> <artifactId>apache</artifactId> <version>18</version> </parent> <groupId>org.apache.maven.ci</groupId> <artifactId>ci-parent</artifactId> <name>First CI Friendly</name> <version>${revision}</version> … <properties> <revision>1.0.0-SNAPSHOT</revision> </properties> <modules> <module>child1</module> .. </modules> </project> … Read more

Extend data class in Kotlin

The truth is: data classes do not play too well with inheritance. We are considering prohibiting or severely restricting inheritance of data classes. For example, it’s known that there’s no way to implement equals() correctly in a hierarchy on non-abstract classes. So, all I can offer: don’t use inheritance with data classes.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)