File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @description
3+ * Something do for Error handle
4+ *
5+ * @param {unknown } error Error Object
6+ * @returns {void }
7+ */
8+ export default function ErrorHandle ( error : unknown ) : void {
9+ if ( error instanceof Error ) {
10+ console . error ( '❌ Error:' , error . message ) ;
11+
12+ if ( error . stack ) {
13+ console . error ( 'Stack trace:' , error . stack ) ;
14+ }
15+ } else if ( typeof error === 'string' ) {
16+ console . error ( '❌ Error:' , error ) ;
17+ } else {
18+ console . error ( '❌ Unknown error occurred:' , error ) ;
19+ }
20+
21+ process . exit ( 1 ) ;
22+ }
23+
24+ /**
25+ * @description
26+ * Log the error and decide whether to continue
27+ *
28+ * @param {unknown } error Error Object
29+ * @param {string } context Error context
30+ * @returns {boolean } Whether to continue
31+ */
32+ export function logErrorAndContinue ( error : unknown , context ?: string ) : boolean {
33+ const prefix = context ? `[${ context } ]` : '' ;
34+
35+ if ( error instanceof Error ) {
36+ console . warn ( `⚠️ ${ prefix } Warning:` , error . message ) ;
37+ } else if ( typeof error === 'string' ) {
38+ console . warn ( `⚠️ ${ prefix } Warning:` , error ) ;
39+ } else {
40+ console . warn ( `⚠️ ${ prefix } Unknown warning:` , error ) ;
41+ }
42+
43+ return true ; // 계속 진행
44+ }
You can’t perform that action at this time.
0 commit comments