mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
do not propagate errors
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/micro/micro/v3/service/client"
|
"github.com/micro/micro/v3/service/client"
|
||||||
|
"github.com/micro/micro/v3/service/errors"
|
||||||
"github.com/micro/micro/v3/service/logger"
|
"github.com/micro/micro/v3/service/logger"
|
||||||
iproto "github.com/micro/services/image/proto"
|
iproto "github.com/micro/services/image/proto"
|
||||||
thumbnail "github.com/micro/services/thumbnail/proto"
|
thumbnail "github.com/micro/services/thumbnail/proto"
|
||||||
@@ -50,11 +51,12 @@ func (e *Thumbnail) Screenshot(ctx context.Context, req *thumbnail.ScreenshotReq
|
|||||||
logger.Info(string(outp))
|
logger.Info(string(outp))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(string(outp) + err.Error())
|
logger.Error(string(outp) + err.Error())
|
||||||
return err
|
return errors.InternalServerError("thumbnail.Screenshot", "Error taking screenshot")
|
||||||
}
|
}
|
||||||
file, err := ioutil.ReadFile(imagePath)
|
file, err := ioutil.ReadFile(imagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
logger.Errorf("Error reading file %s", err)
|
||||||
|
return errors.InternalServerError("thumbnail.Screenshot", "Error taking screenshot")
|
||||||
}
|
}
|
||||||
base := base64.StdEncoding.EncodeToString(file)
|
base := base64.StdEncoding.EncodeToString(file)
|
||||||
resp, err := e.imageService.Upload(ctx, &iproto.UploadRequest{
|
resp, err := e.imageService.Upload(ctx, &iproto.UploadRequest{
|
||||||
@@ -62,7 +64,8 @@ func (e *Thumbnail) Screenshot(ctx context.Context, req *thumbnail.ScreenshotReq
|
|||||||
Name: imageName,
|
Name: imageName,
|
||||||
}, client.WithDialTimeout(20*time.Second), client.WithRequestTimeout(20*time.Second))
|
}, client.WithDialTimeout(20*time.Second), client.WithRequestTimeout(20*time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
logger.Errorf("Error uploading screenshot %s", err)
|
||||||
|
return errors.InternalServerError("thumbnail.Screenshot", "Error taking screenshot")
|
||||||
}
|
}
|
||||||
rsp.ImageURL = resp.Url
|
rsp.ImageURL = resp.Url
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user