File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -255,8 +255,29 @@ program
255255 }
256256 } catch ( error ) {
257257 const errAny = error as any ;
258- const message = error instanceof Error ? error . message : String ( error ) ;
258+ let message = "" ;
259+ if ( error instanceof Error && error . message ) {
260+ message = error . message ;
261+ } else if ( errAny && typeof errAny === "object" && typeof errAny . message === "string" && errAny . message ) {
262+ message = errAny . message ;
263+ } else {
264+ message = String ( error ) ;
265+ }
266+ if ( ! message || message === "[object Object]" ) {
267+ message = "Unknown error" ;
268+ }
259269 console . error ( `✗ init failed: ${ message } ` ) ;
270+ if ( errAny && typeof errAny === "object" ) {
271+ if ( typeof errAny . code === "string" && errAny . code ) {
272+ console . error ( `Error code: ${ errAny . code } ` ) ;
273+ }
274+ if ( typeof errAny . detail === "string" && errAny . detail ) {
275+ console . error ( `Detail: ${ errAny . detail } ` ) ;
276+ }
277+ if ( typeof errAny . hint === "string" && errAny . hint ) {
278+ console . error ( `Hint: ${ errAny . hint } ` ) ;
279+ }
280+ }
260281 if ( errAny && typeof errAny === "object" && typeof errAny . code === "string" ) {
261282 if ( errAny . code === "42501" ) {
262283 console . error ( "Hint: connect as a superuser (or a role with CREATEROLE and sufficient GRANT privileges)." ) ;
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ test("resolveAdminConnection rejects when only PGPASSWORD is provided (no connec
9595 assert . throws ( ( ) => init . resolveAdminConnection ( { envPassword : "pw" } ) , / C o n n e c t i o n i s r e q u i r e d / ) ;
9696} ) ;
9797
98+ test ( "resolveAdminConnection error message includes examples" , ( ) => {
99+ assert . throws ( ( ) => init . resolveAdminConnection ( { } ) , / E x a m p l e s : / ) ;
100+ } ) ;
101+
98102test ( "print-sql redaction regex matches password literal with embedded quotes" , async ( ) => {
99103 const plan = await init . buildInitPlan ( {
100104 database : "mydb" ,
You can’t perform that action at this time.
0 commit comments