2
0
Эх сурвалжийг харах

Throw NotImplementedException in std instead of strings (#9687)

* throw NotImplementedException instead of strings

* drop "Not implemented" messages

* fix find&replace
Aleksandr Kuzmenko 5 жил өмнө
parent
commit
069c8d666b

+ 1 - 1
std/DateTools.hx

@@ -98,7 +98,7 @@ class DateTools {
 			case "Y":
 			case "Y":
 				Std.string(d.getFullYear());
 				Std.string(d.getFullYear());
 			default:
 			default:
-				throw "Date.format %" + e + "- not implemented yet.";
+				throw new haxe.exceptions.NotImplementedException("Date.format %" + e + "- not implemented yet.");
 		}
 		}
 	}
 	}
 
 

+ 1 - 1
std/EReg.hx

@@ -45,7 +45,7 @@ class EReg {
 		If `r` or `opt` are null, the result is unspecified.
 		If `r` or `opt` are null, the result is unspecified.
 	**/
 	**/
 	public function new(r:String, opt:String) {
 	public function new(r:String, opt:String) {
-		throw "Regular expressions are not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Regular expressions are not implemented for this platform");
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
std/cs/internal/HxObject.hx

@@ -276,7 +276,7 @@ class HxEnum {
 	}
 	}
 
 
 	public function getTag():String {
 	public function getTag():String {
-		return throw 'Not Implemented';
+		return throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function getParams():Array<{}> {
 	public function getParams():Array<{}> {

+ 2 - 2
std/eval/_std/sys/ssl/Socket.hx

@@ -181,7 +181,7 @@ class Socket extends sys.net.Socket {
 	}
 	}
 
 
 	public function addSNICertificate(cbServernameMatch:String->Bool, cert:Certificate, key:Key):Void {
 	public function addSNICertificate(cbServernameMatch:String->Bool, cert:Certificate, key:Key):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function peerCertificate():Certificate {
 	public function peerCertificate():Certificate {
@@ -189,7 +189,7 @@ class Socket extends sys.net.Socket {
 	}
 	}
 
 
 	public function setCertificate(cert:Certificate, key:Key):Void {
 	public function setCertificate(cert:Certificate, key:Key):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	private function buildConfig(server:Bool):Config {
 	private function buildConfig(server:Bool):Config {

+ 1 - 1
std/flash/_std/haxe/zip/Compress.hx

@@ -25,7 +25,7 @@ package haxe.zip;
 @:coreApi
 @:coreApi
 class Compress {
 class Compress {
 	public function new(level:Int):Void {
 	public function new(level:Int):Void {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 	}
 	}
 
 
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {

+ 1 - 1
std/flash/_std/haxe/zip/Uncompress.hx

@@ -25,7 +25,7 @@ package haxe.zip;
 @:coreApi
 @:coreApi
 class Uncompress {
 class Uncompress {
 	public function new(?windowBits:Int):Void {
 	public function new(?windowBits:Int):Void {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 	}
 	}
 
 
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {

+ 1 - 1
std/haxe/Log.hx

@@ -69,7 +69,7 @@ class Log {
 		#elseif sys
 		#elseif sys
 		Sys.println(str);
 		Sys.println(str);
 		#else
 		#else
-		throw "Not implemented"
+		throw new haxe.exceptions.NotImplementedException()
 		#end
 		#end
 	}
 	}
 }
 }

+ 2 - 2
std/haxe/Utf8.hx

@@ -63,7 +63,7 @@ class Utf8 {
 		Encode the input ISO string into the corresponding UTF8 one.
 		Encode the input ISO string into the corresponding UTF8 one.
 	**/
 	**/
 	public static function encode(s:String):String {
 	public static function encode(s:String):String {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	/**
 	/**
@@ -71,7 +71,7 @@ class Utf8 {
 		Throw an exception if a given UTF8 character is not supported by the decoder.
 		Throw an exception if a given UTF8 character is not supported by the decoder.
 	**/
 	**/
 	public static function decode(s:String):String {
 	public static function decode(s:String):String {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
std/haxe/ds/WeakMap.hx

@@ -36,7 +36,7 @@ class WeakMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
 		Creates a new WeakMap.
 		Creates a new WeakMap.
 	**/
 	**/
 	public function new():Void {
 	public function new():Void {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
std/haxe/http/HttpBase.hx

@@ -183,7 +183,7 @@ class HttpBase {
 		this method returns.
 		this method returns.
 	**/
 	**/
 	public function request(?post:Bool):Void {
 	public function request(?post:Bool):Void {
-		throw "not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 2
std/haxe/io/Input.hx

@@ -48,9 +48,9 @@ class Input {
 	**/
 	**/
 	public function readByte():Int {
 	public function readByte():Int {
 		#if cpp
 		#if cpp
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		#else
 		#else
-		return throw "Not implemented";
+		return throw new haxe.exceptions.NotImplementedException();
 		#end
 		#end
 	}
 	}
 
 

+ 1 - 1
std/haxe/io/Output.hx

@@ -44,7 +44,7 @@ class Output {
 		Write one byte.
 		Write one byte.
 	**/
 	**/
 	public function writeByte(c:Int):Void {
 	public function writeByte(c:Int):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 2
std/haxe/zip/Compress.hx

@@ -24,7 +24,7 @@ package haxe.zip;
 
 
 class Compress {
 class Compress {
 	public function new(level:Int) {
 	public function new(level:Int) {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 	}
 	}
 
 
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
@@ -36,7 +36,7 @@ class Compress {
 	public function close() {}
 	public function close() {}
 
 
 	public static function run(s:haxe.io.Bytes, level:Int):haxe.io.Bytes {
 	public static function run(s:haxe.io.Bytes, level:Int):haxe.io.Bytes {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 		return null;
 		return null;
 	}
 	}
 }
 }

+ 1 - 1
std/haxe/zip/Uncompress.hx

@@ -24,7 +24,7 @@ package haxe.zip;
 
 
 class Uncompress {
 class Uncompress {
 	public function new(?windowBits:Int) {
 	public function new(?windowBits:Int) {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 	}
 	}
 
 
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {
 	public function execute(src:haxe.io.Bytes, srcPos:Int, dst:haxe.io.Bytes, dstPos:Int):{done:Bool, read:Int, write:Int} {

+ 17 - 17
std/hl/types/ArrayBase.hx

@@ -25,16 +25,16 @@ package hl.types;
 @:keep
 @:keep
 class ArrayAccess {
 class ArrayAccess {
 	public function getDyn(pos:Int):Dynamic {
 	public function getDyn(pos:Int):Dynamic {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return 0;
 		return 0;
 	}
 	}
 
 
 	public function setDyn(pos:Int, v:Dynamic) {
 	public function setDyn(pos:Int, v:Dynamic) {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function blit(pos:Int, src:ArrayAccess, srcpos:Int, len:Int):Void {
 	public function blit(pos:Int, src:ArrayAccess, srcpos:Int, len:Int):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 }
 }
 
 
@@ -43,67 +43,67 @@ class ArrayBase extends ArrayAccess {
 	public var length(default, null):Int;
 	public var length(default, null):Int;
 
 
 	public function pushDyn(v:Dynamic):Int {
 	public function pushDyn(v:Dynamic):Int {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return 0;
 		return 0;
 	}
 	}
 
 
 	public function popDyn():Null<Dynamic> {
 	public function popDyn():Null<Dynamic> {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 
 	public function shiftDyn():Null<Dynamic> {
 	public function shiftDyn():Null<Dynamic> {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 
 	public function unshiftDyn(v:Dynamic):Void {
 	public function unshiftDyn(v:Dynamic):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function insertDyn(pos:Int, v:Dynamic):Void {
 	public function insertDyn(pos:Int, v:Dynamic):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function containsDyn(v:Dynamic):Bool {
 	public function containsDyn(v:Dynamic):Bool {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return false;
 		return false;
 	}
 	}
 
 
 	public function removeDyn(v:Dynamic):Bool {
 	public function removeDyn(v:Dynamic):Bool {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return false;
 		return false;
 	}
 	}
 
 
 	public function sortDyn(f:Dynamic->Dynamic->Int):Void {
 	public function sortDyn(f:Dynamic->Dynamic->Int):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function slice(pos:Int, ?end:Int):ArrayBase {
 	public function slice(pos:Int, ?end:Int):ArrayBase {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 
 	public function splice(pos:Int, len:Int):ArrayBase {
 	public function splice(pos:Int, len:Int):ArrayBase {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 
 	public function join(sep:String):String {
 	public function join(sep:String):String {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 
 	public function reverse() {
 	public function reverse() {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function resize(len:Int) {
 	public function resize(len:Int) {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function toString():String {
 	public function toString():String {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 

+ 3 - 3
std/java/_std/Sys.hx

@@ -50,7 +50,7 @@ using haxe.Int64;
 
 
 	public static function putEnv(s:String, v:String):Void {
 	public static function putEnv(s:String, v:String):Void {
 		// java offers no support for it (!)
 		// java offers no support for it (!)
-		throw "Not implemented in this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented in this platform");
 	}
 	}
 
 
 	public static function environment():Map<String, String> {
 	public static function environment():Map<String, String> {
@@ -81,7 +81,7 @@ using haxe.Int64;
 
 
 	public static function setCwd(s:String):Void {
 	public static function setCwd(s:String):Void {
 		// java offers no support for it (!)
 		// java offers no support for it (!)
-		throw "not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public static function systemName():String {
 	public static function systemName():String {
@@ -146,7 +146,7 @@ using haxe.Int64;
 
 
 	public static function getChar(echo:Bool):Int {
 	public static function getChar(echo:Bool):Int {
 		// TODO
 		// TODO
-		return throw "Not implemented";
+		return throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public static function stdin():haxe.io.Input {
 	public static function stdin():haxe.io.Input {

+ 2 - 2
std/java/_std/haxe/zip/Compress.hx

@@ -30,7 +30,7 @@ class Compress {
 	var finish:Bool = false;
 	var finish:Bool = false;
 
 
 	public function new(level:Int) {
 	public function new(level:Int) {
-		throw "Not implemented for this platform"; // FIXME: Add unit tests for Compress/Uncompress and check current implementation
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform"); // FIXME: Add unit tests for Compress/Uncompress and check current implementation
 		this.deflater = new Deflater(level);
 		this.deflater = new Deflater(level);
 		this.mode = Deflater.NO_FLUSH;
 		this.mode = Deflater.NO_FLUSH;
 	}
 	}
@@ -58,7 +58,7 @@ class Compress {
 				this.finish = true;
 				this.finish = true;
 				Deflater.FULL_FLUSH;
 				Deflater.FULL_FLUSH;
 			case BLOCK:
 			case BLOCK:
-				throw "Not Implemented";
+				throw new haxe.exceptions.NotImplementedException();
 		}
 		}
 	}
 	}
 
 

+ 3 - 3
std/java/_std/sys/net/Socket.hx

@@ -142,11 +142,11 @@ class Socket {
 	}
 	}
 
 
 	public function waitForRead():Void {
 	public function waitForRead():Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function setBlocking(b:Bool):Void {
 	public function setBlocking(b:Bool):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function setFastSend(b:Bool):Void {
 	public function setFastSend(b:Bool):Void {
@@ -158,7 +158,7 @@ class Socket {
 
 
 	public static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
 	public static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
 			?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>} {
 			?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>} {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 }
 }

+ 1 - 1
std/java/internal/HxObject.hx

@@ -221,7 +221,7 @@ class HxEnum {
 	}
 	}
 
 
 	public function getTag():String {
 	public function getTag():String {
-		return throw 'Not Implemented';
+		return throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 
 
 	public function getParams():Array<{}> {
 	public function getParams():Array<{}> {

+ 2 - 2
std/php/net/Socket.hx

@@ -81,7 +81,7 @@ class Socket extends sys.net.Socket {
 	}
 	}
 
 
 	override public function listen(connections:Int):Void {
 	override public function listen(connections:Int):Void {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		/* TODO: ??????
 		/* TODO: ??????
 			var r = socket_listen(__s, connections);
 			var r = socket_listen(__s, connections);
 			checkError(r);
 			checkError(r);
@@ -155,7 +155,7 @@ class Socket extends sys.net.Socket {
 
 
 	public static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
 	public static function select(read:Array<Socket>, write:Array<Socket>, others:Array<Socket>,
 			?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>} {
 			?timeout:Float):{read:Array<Socket>, write:Array<Socket>, others:Array<Socket>} {
-		throw "Not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 		return null;
 		return null;
 	}
 	}
 
 

+ 1 - 1
std/python/net/SslSocket.hx

@@ -53,6 +53,6 @@ class SslSocket extends sys.net.Socket {
 	}
 	}
 
 
 	public override function bind(host:Host, port:Int):Void {
 	public override function bind(host:Host, port:Int):Void {
-		throw "not implemented";
+		throw new haxe.exceptions.NotImplementedException();
 	}
 	}
 }
 }

+ 1 - 1
std/sys/Http.hx

@@ -109,7 +109,7 @@ class Http extends haxe.http.HttpBase {
 				#elseif (neko || cpp)
 				#elseif (neko || cpp)
 				throw "Https is only supported with -lib hxssl";
 				throw "Https is only supported with -lib hxssl";
 				#else
 				#else
-				throw "Https support in haxe.Http is not implemented for this target";
+				throw new haxe.exceptions.NotImplementedException("Https support in haxe.Http is not implemented for this target");
 				#end
 				#end
 			} else {
 			} else {
 				sock = new Socket();
 				sock = new Socket();

+ 1 - 1
std/sys/db/Mysql.hx

@@ -31,7 +31,7 @@ class Mysql {
 		?socket:String,
 		?socket:String,
 		?database:String
 		?database:String
 	}):sys.db.Connection {
 	}):sys.db.Connection {
-		throw "Not implemented for this platform";
+		throw new haxe.exceptions.NotImplementedException("Not implemented for this platform");
 		return null;
 		return null;
 	}
 	}
 }
 }

+ 1 - 1
tests/unit/src/unit/issues/Issue3777.hx

@@ -2,7 +2,7 @@ package unit.issues;
 
 
 private class A<T:String> {
 private class A<T:String> {
 	public function new() f();
 	public function new() f();
-	function f():haxe.ds.Map<T,Int> throw "not implemented";
+	function f():haxe.ds.Map<T,Int> throw new haxe.exceptions.NotImplementedException();
 }
 }
 
 
 private class B extends A<String> {
 private class B extends A<String> {