feat: enhance dev error reports
This commit is contained in:
		
				
					committed by
					
						 Mrugesh Mohapatra
						Mrugesh Mohapatra
					
				
			
			
				
	
			
			
			
						parent
						
							10a6622546
						
					
				
				
					commit
					f378f54ac3
				
			| @@ -6,6 +6,21 @@ import { homeLocation } from '../../../config/env'; | ||||
|  | ||||
| import { unwrapHandledError } from '../utils/create-handled-error.js'; | ||||
|  | ||||
| const errTemplate = (error, req) => { | ||||
|   const { message, stack } = error; | ||||
|   return ` | ||||
| Error: ${message} | ||||
| Is authenticated user: ${!!req.user} | ||||
| Headers: ${JSON.stringify(req.headers, null, 2)} | ||||
| Original request: ${req.originalMethod} ${req.originalUrl} | ||||
| Stack: ${stack} | ||||
|  | ||||
| // raw | ||||
| ${JSON.stringify(error, null, 2)} | ||||
|  | ||||
| `; | ||||
| }; | ||||
|  | ||||
| const isDev = process.env.FREECODECAMP_NODE_ENV !== 'production'; | ||||
|  | ||||
| export default function prodErrorHandler() { | ||||
| @@ -30,7 +45,7 @@ export default function prodErrorHandler() { | ||||
|       'Oops! Something went wrong. Please try again in a moment.'; | ||||
|  | ||||
|     if (isDev) { | ||||
|       console.error(err); | ||||
|       console.error(errTemplate(err, req)); | ||||
|     } | ||||
|  | ||||
|     if (type === 'html') { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user