| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Jarid Margolin @jaridmargolin | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 17:27:56 +08:00
										 |  |  | const inspect = require("util").inspect.custom; | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | const makeSerializable = require("./util/makeSerializable"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | /** @typedef {import("./Chunk")} Chunk */ | 
					
						
							| 
									
										
										
										
											2018-07-14 03:30:55 +08:00
										 |  |  | /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | 
					
						
							| 
									
										
										
										
											2020-01-21 05:36:47 +08:00
										 |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							| 
									
										
										
										
											2023-04-12 02:57:43 +08:00
										 |  |  | /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | 
					
						
							|  |  |  | /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | 
					
						
							| 
									
										
										
										
											2018-07-14 03:30:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | class WebpackError extends Error { | 
					
						
							| 
									
										
										
										
											2018-05-07 14:19:41 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Creates an instance of WebpackError. | 
					
						
							|  |  |  | 	 * @param {string=} message error message | 
					
						
							| 
									
										
										
										
											2025-04-23 05:24:52 +08:00
										 |  |  | 	 * @param {{ cause?: unknown }} options error options | 
					
						
							| 
									
										
										
										
											2018-05-07 14:19:41 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2025-04-23 05:24:52 +08:00
										 |  |  | 	constructor(message, options = {}) { | 
					
						
							| 
									
										
										
										
											2025-04-23 06:27:18 +08:00
										 |  |  | 		// @ts-expect-error ES2018 doesn't `Error.cause`, but it can be used by developers
 | 
					
						
							| 
									
										
										
										
											2025-04-23 05:24:52 +08:00
										 |  |  | 		super(message, options); | 
					
						
							| 
									
										
										
										
											2018-04-08 08:44:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-14 23:15:13 +08:00
										 |  |  | 		/** @type {string=} */ | 
					
						
							| 
									
										
										
										
											2018-04-12 00:44:28 +08:00
										 |  |  | 		this.details = undefined; | 
					
						
							| 
									
										
										
										
											2024-03-14 23:15:13 +08:00
										 |  |  | 		/** @type {(Module | null)=} */ | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | 		this.module = undefined; | 
					
						
							| 
									
										
										
										
											2024-03-14 23:15:13 +08:00
										 |  |  | 		/** @type {DependencyLocation=} */ | 
					
						
							| 
									
										
										
										
											2018-07-14 03:30:55 +08:00
										 |  |  | 		this.loc = undefined; | 
					
						
							| 
									
										
										
										
											2024-03-14 23:15:13 +08:00
										 |  |  | 		/** @type {boolean=} */ | 
					
						
							| 
									
										
										
										
											2018-10-25 16:49:51 +08:00
										 |  |  | 		this.hideStack = undefined; | 
					
						
							| 
									
										
										
										
											2024-03-14 23:15:13 +08:00
										 |  |  | 		/** @type {Chunk=} */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 		this.chunk = undefined; | 
					
						
							| 
									
										
										
										
											2024-03-14 23:15:13 +08:00
										 |  |  | 		/** @type {string=} */ | 
					
						
							| 
									
										
										
										
											2018-12-19 01:29:12 +08:00
										 |  |  | 		this.file = undefined; | 
					
						
							| 
									
										
										
										
											2018-04-06 13:59:58 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 17:27:56 +08:00
										 |  |  | 	[inspect]() { | 
					
						
							| 
									
										
										
										
											2025-04-23 05:24:52 +08:00
										 |  |  | 		return ( | 
					
						
							|  |  |  | 			this.stack + | 
					
						
							|  |  |  | 			(this.details ? `\n${this.details}` : "") + | 
					
						
							|  |  |  | 			(this.cause ? `\n${this.cause}` : "") | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-03-25 05:17:47 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 02:57:43 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ObjectSerializerContext} context context | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-10-25 16:49:51 +08:00
										 |  |  | 	serialize({ write }) { | 
					
						
							|  |  |  | 		write(this.name); | 
					
						
							|  |  |  | 		write(this.message); | 
					
						
							|  |  |  | 		write(this.stack); | 
					
						
							| 
									
										
										
										
											2025-04-23 05:24:52 +08:00
										 |  |  | 		write(this.cause); | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | 		write(this.details); | 
					
						
							|  |  |  | 		write(this.loc); | 
					
						
							| 
									
										
										
										
											2018-10-25 16:49:51 +08:00
										 |  |  | 		write(this.hideStack); | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-12 02:57:43 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ObjectDeserializerContext} context context | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-10-25 16:49:51 +08:00
										 |  |  | 	deserialize({ read }) { | 
					
						
							|  |  |  | 		this.name = read(); | 
					
						
							|  |  |  | 		this.message = read(); | 
					
						
							|  |  |  | 		this.stack = read(); | 
					
						
							| 
									
										
										
										
											2025-04-23 05:24:52 +08:00
										 |  |  | 		this.cause = read(); | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | 		this.details = read(); | 
					
						
							|  |  |  | 		this.loc = read(); | 
					
						
							| 
									
										
										
										
											2018-10-25 16:49:51 +08:00
										 |  |  | 		this.hideStack = read(); | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-25 16:47:52 +08:00
										 |  |  | makeSerializable(WebpackError, "webpack/lib/WebpackError"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-04 00:57:02 +08:00
										 |  |  | module.exports = WebpackError; |