File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/publish/quarto-pub/api Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -192,7 +192,8 @@ export class QuartoPubClient {
192192
193193 // If the response was not OK, throw an ApiError.
194194 if ( ! response . ok ) {
195- throw new ApiError ( response . status , response . statusText ) ;
195+ const description = await descriptionFromErrorResponse ( response ) ;
196+ throw new ApiError ( response . status , description || response . statusText ) ;
196197 }
197198
198199 // Return the result.
@@ -266,3 +267,17 @@ export class QuartoPubClient {
266267 // Creates a URL.
267268 private createURL = ( path : string ) => `${ this . baseURL_ } /${ path } ` ;
268269}
270+
271+ async function descriptionFromErrorResponse ( response : Response ) {
272+ // if there is a body, see if its a quarto pub error w/ description
273+ if ( response . body ) {
274+ try {
275+ const result = await response . json ( ) ;
276+ if ( typeof ( result . description ) === "string" ) {
277+ return result . description ;
278+ }
279+ } catch {
280+ //
281+ }
282+ }
283+ }
You can’t perform that action at this time.
0 commit comments