Fix a bug in error parsing #21
@@ -8,7 +8,8 @@ export default (target, key, descriptor) => {
 | 
				
			|||||||
      await fn(request, reply);
 | 
					      await fn(request, reply);
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
      if (e.original) {
 | 
					      if (e.original) {
 | 
				
			||||||
        const { code, detail } = e.original;
 | 
					        const { code, detail, hint } = e.original;
 | 
				
			||||||
 | 
					        let error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // pg error codes https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
 | 
					        // pg error codes https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
 | 
				
			||||||
        if (code && (code.startsWith('22') || code.startsWith('23'))) {
 | 
					        if (code && (code.startsWith('22') || code.startsWith('23'))) {
 | 
				
			||||||
@@ -20,6 +21,10 @@ export default (target, key, descriptor) => {
 | 
				
			|||||||
          error.reformat();
 | 
					          error.reformat();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // hint might provide useful information about how to fix the problem
 | 
				
			||||||
 | 
					        if (hint) {
 | 
				
			||||||
 | 
					          error.message += ` Hint: ${hint}`;
 | 
				
			||||||
 | 
					          error.reformat();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        reply(error);
 | 
					        reply(error);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user