Custom error type creation for JavaScript