mirror of
				https://github.com/lingble/clickhouse.git
				synced 2025-11-04 04:58:06 +00:00 
			
		
		
		
	fix: error code parsing
This commit is contained in:
		
							
								
								
									
										10
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								index.js
									
									
									
									
									
								
							@@ -56,7 +56,7 @@ var ESCAPE_NULL = {
 | 
				
			|||||||
	JSONEachRow: "\\N",
 | 
						JSONEachRow: "\\N",
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const R_ERROR = new RegExp('Code: ([0-9]{2}), .*Exception:');
 | 
					const R_ERROR = new RegExp('(Code|Error): ([0-9]{2})[,.] .*Exception: (.+?)$', 'm');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const URI = 'localhost';
 | 
					const URI = 'localhost';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -232,12 +232,12 @@ function getErrorObj(res) {
 | 
				
			|||||||
	if (res.body) {
 | 
						if (res.body) {
 | 
				
			||||||
		const m = res.body.match(R_ERROR);
 | 
							const m = res.body.match(R_ERROR);
 | 
				
			||||||
		if (m) {
 | 
							if (m) {
 | 
				
			||||||
			if (m[1] && isNaN(parseInt(m[1])) === false) {
 | 
								if (m[2] && isNaN(parseInt(m[2])) === false) {
 | 
				
			||||||
				err.code = parseInt(m[1]);
 | 
									err.code = parseInt(m[2]);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			if (m[2]) {
 | 
								if (m[3]) {
 | 
				
			||||||
				err.message = m[2];
 | 
									err.message = m[3];
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,5 +91,5 @@
 | 
				
			|||||||
    "test": "mocha --bail --timeout 60000 --slow 5000"
 | 
					    "test": "mocha --bail --timeout 60000 --slow 5000"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "types": "index.d.ts",
 | 
					  "types": "index.d.ts",
 | 
				
			||||||
  "version": "2.4.1"
 | 
					  "version": "2.4.2"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user