@@ -228,7 +228,7 @@ func getServicePath(orgSlug, serviceSlug string) string {
228228func (s * Session ) GetService (ctx context.Context , orgSlug , serviceSlug string ) (* Service , error ) {
229229 var svc Service
230230 if err := s .get (ctx , getServicePath (orgSlug , serviceSlug ), & svc ); err != nil {
231- if err == NotFoundErr {
231+ if errors . Is ( err , NotFoundErr ) {
232232 return nil , nil
233233 }
234234 return nil , err
@@ -248,7 +248,11 @@ func (s *Session) get(ctx context.Context, path string, out any) error {
248248 return err
249249 }
250250 if res .StatusCode != http .StatusOK {
251- return StatusCodeError (res .StatusCode )
251+ var errorsRes * Error
252+ if err = json .NewDecoder (res .Body ).Decode (& errorsRes ); err != nil {
253+ return err
254+ }
255+ return fmt .Errorf ("%w: %s" , StatusCodeError (res .StatusCode ), errorsRes .Title )
252256 }
253257 return json .NewDecoder (res .Body ).Decode (out )
254258}
@@ -274,7 +278,11 @@ func (s *Session) post(ctx context.Context, path string, in, out any) error {
274278 return err
275279 }
276280 if res .StatusCode != http .StatusOK {
277- return fmt .Errorf ("unexpected response code: %d" , res .StatusCode )
281+ var errorsRes * Error
282+ if err = json .NewDecoder (res .Body ).Decode (& errorsRes ); err != nil {
283+ return err
284+ }
285+ return fmt .Errorf ("%w: %s" , StatusCodeError (res .StatusCode ), errorsRes .Title )
278286 }
279287 return json .NewDecoder (res .Body ).Decode (out )
280288}
@@ -351,4 +359,4 @@ type StatusCodeError int
351359const NotFoundErr = StatusCodeError (http .StatusNotFound )
352360
353361func (err StatusCodeError ) StatusCode () int { return int (err ) }
354- func (err StatusCodeError ) Error () string { return fmt .Sprintf ("unexpected response code: %d " , err ) }
362+ func (err StatusCodeError ) Error () string { return fmt .Sprintf ("unexpected %d status response " , err ) }
0 commit comments