| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Ivan Kopeykin @vankop | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const WebpackError = require("./WebpackError"); | 
					
						
							|  |  |  | const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @param {string=} method method name | 
					
						
							|  |  |  |  * @returns {string} message | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function createMessage(method) { | 
					
						
							| 
									
										
										
										
											2024-07-31 10:39:30 +08:00
										 |  |  | 	return `Abstract method${method ? ` ${method}` : ""}. Must be overridden.`; | 
					
						
							| 
									
										
										
										
											2019-07-15 22:19:51 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @constructor | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | function Message() { | 
					
						
							| 
									
										
										
										
											2024-08-07 23:22:25 +08:00
										 |  |  | 	/** @type {string | undefined} */ | 
					
						
							| 
									
										
										
										
											2019-07-15 22:19:51 +08:00
										 |  |  | 	this.stack = undefined; | 
					
						
							|  |  |  | 	Error.captureStackTrace(this); | 
					
						
							| 
									
										
										
										
											2024-08-07 23:22:25 +08:00
										 |  |  | 	/** @type {RegExpMatchArray | null} */ | 
					
						
							|  |  |  | 	const match = | 
					
						
							|  |  |  | 		/** @type {string} */ | 
					
						
							|  |  |  | 		(/** @type {unknown} */ (this.stack)) | 
					
						
							|  |  |  | 			.split("\n")[3] | 
					
						
							|  |  |  | 			.match(CURRENT_METHOD_REGEXP); | 
					
						
							| 
									
										
										
										
											2019-07-15 22:19:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	this.message = match && match[1] ? createMessage(match[1]) : createMessage(); | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Error for abstract method | 
					
						
							|  |  |  |  * @example | 
					
						
							| 
									
										
										
										
											2024-07-30 21:48:58 +08:00
										 |  |  |  * ```js
 | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  |  * class FooClass { | 
					
						
							|  |  |  |  *     abstractMethod() { | 
					
						
							| 
									
										
										
										
											2020-03-10 09:59:46 +08:00
										 |  |  |  *         throw new AbstractMethodError(); // error message: Abstract method FooClass.abstractMethod. Must be overridden.
 | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  |  *     } | 
					
						
							|  |  |  |  * } | 
					
						
							| 
									
										
										
										
											2024-07-30 21:48:58 +08:00
										 |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | class AbstractMethodError extends WebpackError { | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							| 
									
										
										
										
											2019-07-15 22:19:51 +08:00
										 |  |  | 		super(new Message().message); | 
					
						
							| 
									
										
										
										
											2019-07-15 19:17:12 +08:00
										 |  |  | 		this.name = "AbstractMethodError"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = AbstractMethodError; |