@@ -26,14 +26,12 @@ router.post('/', authenticator(), async (req, res, next) => {
26
26
try {
27
27
newPostFields = fieldParsers . proofPostFields ( req . body ) ;
28
28
} catch ( error ) {
29
- logger . error ( logger . getErrorMessage ( error ) ) ;
30
29
return res . status ( 400 ) . send ( { error : logger . getErrorMessage ( error ) } ) ;
31
30
}
32
31
33
32
try {
34
33
image = await cloudinary . upload ( newPostFields . imageDataUrl ) ;
35
34
} catch ( error ) {
36
- logger . error ( logger . getErrorMessage ( error ) ) ;
37
35
return res . status ( 500 ) . send ( { error : 'Something went wrong uploading the photo!' } ) ;
38
36
}
39
37
@@ -46,7 +44,6 @@ router.post('/', authenticator(), async (req, res, next) => {
46
44
await user . save ( ) ;
47
45
return res . status ( 201 ) . send ( savedPost ) ;
48
46
} catch ( error ) {
49
- logger . error ( logger . getErrorMessage ( error ) ) ;
50
47
return next ( error ) ;
51
48
}
52
49
} ) ;
@@ -57,7 +54,6 @@ router.put('/:id', authenticator(), async (req, res, next) => {
57
54
try {
58
55
if ( updatedPostFields . caption ) updatedPostFields . caption = parseStringField ( updatedPostFields . caption , 'caption' ) ;
59
56
} catch ( error ) {
60
- logger . error ( logger . getErrorMessage ( error ) ) ;
61
57
return res . status ( 400 ) . send ( { error : logger . getErrorMessage ( error ) } ) ;
62
58
}
63
59
@@ -70,7 +66,7 @@ router.put('/:id', authenticator(), async (req, res, next) => {
70
66
return res . status ( 200 ) . send ( updatedPost ) ;
71
67
} catch ( error ) {
72
68
const errorMessage = logger . getErrorMessage ( error ) ;
73
- logger . error ( errorMessage ) ;
69
+
74
70
if ( errorMessage === 'Unauthorized' ) return res . status ( 401 ) . send ( { error : errorMessage } ) ;
75
71
76
72
return next ( error ) ;
@@ -83,7 +79,6 @@ router.delete('/:id', authenticator(), async (req, res, next) => {
83
79
return res . status ( 204 ) . end ( ) ;
84
80
} catch ( error ) {
85
81
const errorMessage = logger . getErrorMessage ( error ) ;
86
- logger . error ( errorMessage ) ;
87
82
88
83
if ( / u n a u t h o r i z e d / i. test ( errorMessage ) ) {
89
84
return res . status ( 401 ) . send ( { error : errorMessage } ) ;
0 commit comments