Index: trunk/nv/base/assert.hh
===================================================================
--- trunk/nv/base/assert.hh	(revision 402)
+++ trunk/nv/base/assert.hh	(revision 403)
@@ -10,4 +10,6 @@
  * @brief Assert functions
  */
+// TODO: assert levels
+// TODO: assert should not depend on CORE!
 
 #ifndef NV_BASE_COMMON_HH
@@ -23,27 +25,43 @@
 #endif
 
-#if NV_COMPILER == NV_MSVC
-void nv_internal_assert( const wchar_t * message, const wchar_t* file, unsigned line );
-#	if NV_DEBUG
-#	define NV_ASSERT_IMPL(cond) (void)( (!!(cond)) || (nv_internal_assert(NV_WIDE(#cond), NV_WIDE(__FILE__), __LINE__), 0) )
+#ifdef assert
+#undef assert
+#endif
+
+namespace nv
+{
+	namespace detail
+	{
+		NV_NORETURN void abort( const char * msg, const char * file, unsigned int line, const char * function );
+		NV_NORETURN void assert_abort( const char * msg, const char * file, unsigned int line, const char * function );
+#if NV_DEBUG
+#	if NV_COMPILER == NV_MSVC
+		NV_NORETURN void assert_fail( const wchar_t * message, const wchar_t* file, unsigned line );
 #	else
-#	define NV_ASSERT_IMPL(cond) 
-#	endif
-#else
-void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function );
-#	if NV_DEBUG
-#	define NV_ASSERT_IMPL(cond) ((cond) ? static_cast<void>(0) : nv_internal_assert(NV_STRINGIZE(cond), __FILE__, __LINE__, __PRETTY_FUNCTION__))
-#	else
-#	define NV_ASSERT_IMPL(cond) 
+		NV_NORETURN void assert_fail( const char * assertion, const char * file, unsigned int line, const char * function );
 #	endif
 #endif
+	}
 
-// TODO: assert levels
+	NV_NORETURN void exit( int ret_val );
+}
+
+
+
+#define NV_ABORT( msg ) ::nv::detail::abort( msg, __FILE__, __LINE__, NV_FUNC_SIG )
+
 #if NV_DEBUG
-#define NV_ASSERT(cond, msg) NV_ASSERT_IMPL( (cond) && "assertion failed:" msg )
-#define NV_DEBUG_ASSERT(cond, msg) NV_ASSERT_IMPL( (cond) && "assertion failed:" msg )
+#	if NV_COMPILER == NV_MSVC
+#	define NV_ASSERT_COND(cond) (void)( (!!(cond)) || (::nv::detail::assert_fail(NV_WIDE(#cond), NV_WIDE(__FILE__), __LINE__), 0) )
+#	else
+#	define NV_ASSERT_COND(cond) ((cond) ? static_cast<void>(0) : ::nv::detail::assert_fail(NV_STRINGIZE(cond), __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#	endif
+#define NV_ASSERT(cond, msg) NV_ASSERT_COND( (cond) && "assertion failed:" msg )
+#define NV_ASSERT_DEBUG(cond, msg) NV_ASSERT_COND( (cond) && "assertion failed:" msg )
+#define NV_ASSERT_ALWAYS(cond, msg) NV_ASSERT_COND( (cond) && "assertion failed:" msg )
 #else  
 #define NV_ASSERT(cond, msg) ((void)0)
-#define NV_DEBUG_ASSERT(cond, msg) ((void)0)
+#define NV_ASSERT_DEBUG(cond, msg) ((void)0)
+#define NV_ASSERT_ALWAYS(cond, msg) ((cond) ? static_cast<void>(0) : ::nv::detail::assert_abort(NV_STRINGIZE(cond) " " msg, __FILE__, __LINE__, NV_FUNC_SIG ))
 #endif 
 
Index: trunk/nv/base/common.hh
===================================================================
--- trunk/nv/base/common.hh	(revision 402)
+++ trunk/nv/base/common.hh	(revision 403)
@@ -128,5 +128,7 @@
 
 #if NV_COMPILER == NV_MSVC
+#define NV_FUNC_SIG __FUNCSIG__
 #define NV_DEPRECATED(func) __declspec(deprecated) func
+#define NV_NORETURN __declspec(noreturn)
 #define NV_NOALIAS __declspec(noalias)
 #define NV_RESTRICT __declspec(restrict)
@@ -139,5 +141,7 @@
 #endif  
 #elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
+#define NV_FUNC_SIG __PRETTY_FUNCTION__
 #define NV_DEPRECATED(func) func __attribute__ ((deprecated))
+#define NV_NORETURN __attribute__ ((__noreturn__))
 #define NV_RESTRICT __restrict__
 #define NV_RESTRICT_VAR __restrict__
@@ -149,8 +153,4 @@
 
 #define NV_UNUSED(x) (void)(x)
-#define NV_THROW(eobj, ...) { \
-	NV_LOG_ERROR( __FILE__ " line " NV_STRINGIZE(__LINE__) " - exception thrown - " #eobj ); \
-	throw eobj( __VA_ARGS__ ); \
-} 
 
 // MSVC and GCC is too stupid to notice fully covered enums, clang 
Index: trunk/nv/core/library.hh
===================================================================
--- trunk/nv/core/library.hh	(revision 402)
+++ trunk/nv/core/library.hh	(revision 403)
@@ -15,5 +15,4 @@
 
 #include <nv/common.hh>
-#include <nv/stl/exception.hh>
 #include <nv/stl/string.hh>
 #include <string>
@@ -113,26 +112,4 @@
 	};  // class Library
 
-	class library_error : public runtime_error
-	{
-		/// Library name
-		std::string m_name;
-	public:
-		/**
-		 * Constructor
-		 */
-		library_error( const std::string& message, const std::string& name )
-			: runtime_error( "Library (" + name + ") : " + message + " [ " + library::get_error() + " ]"), m_name( name )
-		{
-		}
-
-		/**
-		 * Returns library name
-		 */
-		const std::string& get_name()
-		{
-			return m_name;
-		}
-	};
-
 } // namespace nv
 
Index: trunk/nv/stl/algorithm/raw.hh
===================================================================
--- trunk/nv/stl/algorithm/raw.hh	(revision 402)
+++ trunk/nv/stl/algorithm/raw.hh	(revision 403)
@@ -34,5 +34,5 @@
 	T* raw_copy( const T* first, const T* last, T* out )
 	{
-		NV_DEBUG_ASSERT( last - first > 0, "raw_copy range fail!" );
+		NV_ASSERT_DEBUG( last - first > 0, "raw_copy range fail!" );
 		return static_cast<T*>( nvmemcpy( out, first, detail::byte_distance( first, last ) ) ) + ( last - first );
 	}
@@ -47,5 +47,5 @@
 	T* raw_alias_copy( const T* first, const T* last, T* out )
 	{
-		NV_DEBUG_ASSERT( last - first > 0, "raw_alias_copy range fail!" );
+		NV_ASSERT_DEBUG( last - first > 0, "raw_alias_copy range fail!" );
 		return static_cast<T*>( nvmemmove( out, first, detail::byte_distance( first, last ) ) ) + ( last - first );
 	}
@@ -60,5 +60,5 @@
 	T* raw_zero( T* first, T* last )
 	{
-		NV_DEBUG_ASSERT( last - first > 0, "raw_zero range fail!" );
+		NV_ASSERT_DEBUG( last - first > 0, "raw_zero range fail!" );
 		return static_cast<T*>( nvmemset( first, 0, detail::byte_distance( first, last ) ) ) + ( last - first );
 	}
@@ -73,5 +73,5 @@
 	T* raw_fill( T* first, T* last, unsigned char value )
 	{
-		NV_DEBUG_ASSERT( last - first > 0, "raw_fill range fail!" );
+		NV_ASSERT_DEBUG( last - first > 0, "raw_fill range fail!" );
 		return static_cast<T*>( nvmemset( first, value, detail::byte_distance( first, last ) ) ) + ( last - first );
 	}
Index: trunk/nv/stl/string.hh
===================================================================
--- trunk/nv/stl/string.hh	(revision 402)
+++ trunk/nv/stl/string.hh	(revision 403)
@@ -28,5 +28,4 @@
 #include <nv/stl/type_traits/primary.hh>
 #include <nv/stl/memory.hh>
-#include <nv/stl/exception.hh>
 #include <nv/stl/algorithm.hh>
 #include <nv/stl/functional/hash.hh>
Index: trunk/nv/stl/unordered_map.hh
===================================================================
--- trunk/nv/stl/unordered_map.hh	(revision 402)
+++ trunk/nv/stl/unordered_map.hh	(revision 403)
@@ -20,15 +20,5 @@
 namespace nv
 {
-	template < typename Pair >
-	struct use_first
-	{
-		typedef Pair                      argument_type;
-		typedef typename Pair::first_type result_type;
-		const result_type& operator()( const Pair& arg ) const
-		{
-			return arg.first;
-		}
-	};
-	
+
 	template <
 		typename Key, 
Index: trunk/src/core/library.cc
===================================================================
--- trunk/src/core/library.cc	(revision 402)
+++ trunk/src/core/library.cc	(revision 403)
@@ -44,5 +44,6 @@
 	{
 		m_handle = nullptr;
-		NV_THROW( library_error, "Can't load library!", name.data() );
+		NV_LOG_CRITICAL( "library \"", name, "\" : failed to load!" );
+		NV_ABORT( "Can't load library!" );
 	}
 }
@@ -70,5 +71,5 @@
         return true;
     }
-    NV_LOG_NOTICE( "library : loading '", m_name, "'..." );
+    NV_LOG_NOTICE( "library \"", string_view( m_name ), "\" : loading..." );
 
 	std::string name = m_name;
@@ -84,8 +85,8 @@
     if ( m_handle == NULL )
     {
-		NV_LOG_NOTICE( "library : '", name, "' failed to open." );
+		NV_LOG_NOTICE( "library \"", string_view( name ), "\" : failed to open!" );
 		return false;
     }
-    NV_LOG_NOTICE( "library : '", name, "' loaded." );
+    NV_LOG_NOTICE( "library \"", string_view( name ), "\" : loaded." );
 	return true;
 }
@@ -96,5 +97,6 @@
     if ( !result )
     {
-        NV_THROW( library_error, "Can't find symbol " + std::string(symbol.data(),symbol.size()) + "!", m_name );
+		NV_LOG_CRITICAL( "library \"", string_view( m_name ), "\" : can't find symbol \"", symbol, "\"" );
+		NV_ABORT( "Library symbol load failed!" );
     }
 	return result;
@@ -115,5 +117,5 @@
     if ( ! NV_LIB_CLOSE( m_handle ) )
     {
-        NV_LOG_ERROR( "library : can't close library '", m_name, "'!" );
+        NV_LOG_ERROR( "library \"", string_view( m_name ), "\" : can't close library!" );
     }
     m_handle = nullptr;
Index: trunk/src/gfx/texture_font.cc
===================================================================
--- trunk/src/gfx/texture_font.cc	(revision 402)
+++ trunk/src/gfx/texture_font.cc	(revision 403)
@@ -11,4 +11,10 @@
 
 using namespace nv;
+
+#define NV_CHECK_FREETYPE_ERROR( error, ... ) \
+if ( error != 0 ) { \
+	NV_LOG_CRITICAL( "freetype : ", __VA_ARGS__ ); \
+	NV_ABORT( "freetype : freetype library error!" ); \
+}
 
 texture_glyph::texture_glyph()
@@ -45,11 +51,11 @@
 	 
 	error = FT_Init_FreeType( (FT_Library*)(&m_rlibrary) );
-	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
+	NV_CHECK_FREETYPE_ERROR( error, "error on FT_Init_FreeType, code - ", error );
 
 	error = FT_New_Face( (FT_Library)(m_rlibrary), filename, 0, (FT_Face*)(&m_rface) );
-	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
+	NV_CHECK_FREETYPE_ERROR( error, "error on FT_New_Face, code - ", error );
 
 	error = FT_Set_Char_Size( (FT_Face)(m_rface), (int)(size*64), 0, 72*64, 72 ); 
-	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
+	NV_CHECK_FREETYPE_ERROR( error, "error on FT_Set_Char_Size, code - ", error );
 
     FT_Set_Transform( (FT_Face)(m_rface), &matrix, NULL );
@@ -123,9 +129,5 @@
 		FT_UInt glyph_index = FT_Get_Char_Index( face, c ); 
 		FT_Error error = FT_Load_Glyph( face, glyph_index, flags ); 
-		if ( error )
-		{
-			NV_LOG_ERROR( "FT_Error while loading glyphs, error: ", error, " code: ", c );
-			NV_THROW( std::runtime_error, "FT_Error while loading glyphs" );
-		}
+		NV_CHECK_FREETYPE_ERROR( error, "error on FT_Load_Glyph, gylph '", c ,"' code - ", error );
 
 		FT_GlyphSlot slot   = face->glyph;
@@ -141,6 +143,6 @@
 		if ( r.pos.x < 0 ) 
 		{
-			NV_LOG_ERROR( "Atlas full while loading glyphs, r.pos.x: ", r.pos.x, " code: ", c );
-			NV_THROW( std::runtime_error, "Atlas full while loading glyphs" );
+			NV_LOG_CRITICAL( "texture_font : atlas full while loading glyphs, gylph '", c, "' r.pos.x = ", r.pos.x );
+			NV_ABORT( "texture_font : atlas full while loading gylphs!" );
 		}
 		if (depth == 4)
Index: trunk/src/gl/gl_context.cc
===================================================================
--- trunk/src/gl/gl_context.cc	(revision 402)
+++ trunk/src/gl/gl_context.cc	(revision 403)
@@ -379,9 +379,5 @@
 void gl_context::set_viewport( const ivec4& viewport )
 {
-	if ( viewport.z < 0 || viewport.w < 0 )
-	{
-		NV_THROW( logic_error, "viewport width and height must be greater than zero!");
-	}
-
+	NV_ASSERT_ALWAYS( viewport.z > 0 && viewport.w > 0, "viewport dimensions must be greater than zero!" );
 	m_viewport = viewport;
 	glViewport( viewport.x, viewport.y, viewport.z, viewport.w );
@@ -456,11 +452,9 @@
 	}
 
-	if ( scissor.dim.x < 0 || scissor.dim.y < 0 )
-	{
-		NV_THROW( logic_error, "scissor_test.rect width and height must be greater than zero!" );
-	}
 
 	if ( scissor.enabled )
 	{
+		NV_ASSERT_ALWAYS( scissor.dim.x > 0 && scissor.dim.y > 0, "scissor_test.rect dimension equal to zero!" );
+
 		if ( m_render_state.scissor_test.dim != scissor.dim || m_render_state.scissor_test.pos != scissor.pos )
 		{
@@ -514,12 +508,6 @@
 void gl_context::apply_depth_range( const depth_range& range )
 {
-	if ( range.near < 0.0 || range.near > 1.0 )
-	{
-		NV_THROW( logic_error, "render_state.depth_range.near must be between zero and one!");
-	}
-	if ( range.far < 0.0 || range.far > 1.0 )
-	{
-		NV_THROW( logic_error, "render_state.depth_range.far must be between zero and one!");
-	}
+	NV_ASSERT_ALWAYS( range.near >= 0.0 && range.near <= 1.0, "render_state.depth_range.near must be between zero and one!" );
+	NV_ASSERT_ALWAYS( range.far  >= 0.0 && range.far  <= 1.0, "render_state.depth_range.far must be between zero and one!" );
 
 	if ((m_render_state.depth_range.far  != range.far) ||
Index: trunk/src/gl/gl_device.cc
===================================================================
--- trunk/src/gl/gl_device.cc	(revision 402)
+++ trunk/src/gl/gl_device.cc	(revision 403)
@@ -238,6 +238,6 @@
 		if ( fatal )
 		{
-			NV_LOG_ERROR( "Uniform '", name, "' not found in program!" );
-			NV_THROW( runtime_error, ( "Uniform '"+name+"' not found!" ) );
+			NV_LOG_CRITICAL( "gl_device : uniform '", string_view( name ), "' not found in program!" );
+			NV_ABORT( "gl_device : uniform not found!" );
 		}
 	}
@@ -257,6 +257,6 @@
 		if ( fatal )
 		{
-			NV_LOG_ERROR( "Attribute '", name, "' not found in program!" );
-			NV_THROW( runtime_error, ( "Attribute '"+ name + "' not found!" ) );
+			NV_LOG_CRITICAL( "gl_device : attribute '", string_view( name ), "' not found in program!" );
+			NV_ABORT( "gl_device : attribute not found!" );
 		}
 	}
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 402)
+++ trunk/src/lua/lua_state.cc	(revision 403)
@@ -15,4 +15,9 @@
 
 // stack_guard
+
+#define NV_LUA_ABORT( func, ... ) \
+	NV_LOG_CRITICAL( "lua::" func " : ", __VA_ARGS__ ) \
+	NV_ABORT( "lua::" func " : critical error!" )
+
 
 lua::stack_guard::stack_guard( lua::state* aL )
@@ -424,5 +429,5 @@
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, lua_name.to_string() + " type not registered!" );
+		NV_LUA_ABORT( "state::register_object", lua_name, " type not registered!" );
 	}
 	deep_pointer_copy( -1, o );
@@ -436,10 +441,10 @@
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, storage.to_string() + " storage not registered!" );
+		NV_LUA_ABORT( "state::register_proto", "\"", storage, "\" storage not registered!" );
 	}
 	lua_getfield( m_state, -1, id.data() );
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, id.to_string() + " not found in " + storage.to_string() + " storage!" );
+		NV_LUA_ABORT( "state::register_proto", "\"", id, "\" not found in \"", storage, "\"!" );
 	}
 	return lua::ref( luaL_ref( m_state, LUA_REGISTRYINDEX ) );
@@ -452,5 +457,5 @@
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, lua_name.to_string() + " type not registered!" );
+		NV_LUA_ABORT( "state::register_native_object_method", "\"", lua_name, "\" type not registered!" );
 	}
 	lua_pushcfunction( m_state, f );
@@ -502,5 +507,5 @@
 	if ( has_functions || has_metatable )
 	{
-		lua_pushstring( m_state, "__ptr" );
+		lua_pushliteral( m_state, "__ptr" );
 		lua_pushlightuserdata( m_state, obj );
 		lua_rawset( m_state, -3 );
@@ -569,5 +574,5 @@
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, name.to_string() + " type not registered!" );
+		NV_LUA_ABORT( "state::register_singleton", "\"", name, "\" type not registered!" );
 	}
 	deep_pointer_copy( -1, o );
Index: trunk/src/stl/assert.cc
===================================================================
--- trunk/src/stl/assert.cc	(revision 402)
+++ trunk/src/stl/assert.cc	(revision 403)
@@ -9,48 +9,57 @@
 #include "nv/base/assert.hh"
 #undef NV_BASE_COMMON_HH
+#include "nv/core/logging.hh"
 
+extern "C" {
 #if NV_COMPILER == NV_MSVC
+	NV_NORETURN void __cdecl exit( _In_ int _Code );
+#else
+	void exit( int status_code ) NV_NORETURN;
+#endif
+}
 
-#	if NV_DEBUG
-
+#if NV_DEBUG
+#	if NV_COMPILER == NV_MSVC
 extern "C" {
 	void __cdecl _wassert( const wchar_t * _Message, const wchar_t *_File, unsigned _Line );
 }
 
-void nv_internal_assert( const wchar_t * message, const wchar_t* file, unsigned line )
+void nv::detail::assert_fail( const wchar_t * message, const wchar_t* file, unsigned line )
 {
 	_wassert( message, file, line );
 }
-#	else  
-	void nv_internal_assert( const wchar_t *, const wchar_t*, unsigned ) {}
-#	endif  // NV_DEBUG
-#else // NV_COMPILER
-
-#	if NV_DEBUG
+#	else // NV_COMPILER
 #	if NV_COMPILER == NV_CLANG
 extern "C" {
-	extern void __assert(const char *, const char *, unsigned int, const char *)
-		__attribute__ ((__noreturn__));
+	extern void __assert(const char *, const char *, unsigned int, const char *) NV_NORETURN;
 }
+#define NV_ASSERT_IMPL __assert
 #	else
 extern "C" {
-	extern void __assert_fail(const char *, const char *, unsigned int, const char *)
-		__attribute__ ((__noreturn__));
+	extern void __assert_fail(const char *, const char *, unsigned int, const char *) NV_NORETURN;
 }
+#define NV_ASSERT_IMPL __assert_fail
 #	endif
-__attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
+NV_NORETURN void nv::detail::assert_fail( const char * assertion, const char * file, unsigned int line, const char * function )
 {
-#	if NV_COMPILER == NV_CLANG
-	__assert(assertion, file, line, function );
-#	else
-	__assert_fail(assertion, file, line, function );
-#	endif
-}
-#	else
-void nv_internal_assert( const char * , const char * , unsigned int , const char * )
-{
+	NV_ASSERT_IMPL (assertion, file, line, function );
 }
 #	endif
 
-#endif // NV_COMPILER
+#endif // NV_DEBUG
 
+NV_NORETURN void nv::detail::abort( const char * msg, const char * file, unsigned int line, const char * function )
+{
+	NV_LOG_CRITICAL( "Abort called : ", msg );
+	NV_LOG_CRITICAL( "  in ", file, ":", line, " (", function, ")" );
+	NV_LOG_CRITICAL( "Aborting..." );
+	exit( 1 );
+}
+
+NV_NORETURN void nv::detail::assert_abort( const char * msg, const char * file, unsigned int line, const char * function )
+{
+	NV_LOG_CRITICAL( "Assertion failed: (", msg, ")" );
+	NV_LOG_CRITICAL( "  in ", file, ":", line, " (", function, ")" );
+	NV_LOG_CRITICAL( "Aborting..." );
+	exit( 1 );
+}
