@@ -27,7 +27,7 @@ func handleAuthError(err error, cx *goweb.Context) {
27
27
cx .RespondWithErrorMessage ("Invalid Authorization header" , http .StatusBadRequest )
28
28
return
29
29
}
30
- fmt . Println ("Error at Auth:" , err .Error ())
30
+ log . Error ("Error at Auth: " + err .Error ())
31
31
cx .RespondWithError (http .StatusInternalServerError )
32
32
return
33
33
}
@@ -61,7 +61,7 @@ func (cr *NodeController) Create(cx *goweb.Context) {
61
61
if err .Error () == "request Content-Type isn't multipart/form-data" {
62
62
node , err := store .CreateNodeUpload (u , params , files )
63
63
if err != nil {
64
- fmt . Println ("Error at create empty:" , err .Error ())
64
+ log . Error ("Error at create empty: " + err .Error ())
65
65
cx .RespondWithError (http .StatusInternalServerError )
66
66
return
67
67
}
@@ -78,15 +78,15 @@ func (cr *NodeController) Create(cx *goweb.Context) {
78
78
// Some error other than request encoding. Theoretically
79
79
// could be a lost db connection between user lookup and parsing.
80
80
// Blame the user, Its probaby their fault anyway.
81
- fmt . Println ("Error parsing form:" , err .Error ())
81
+ log . Error ("Error parsing form: " + err .Error ())
82
82
cx .RespondWithError (http .StatusBadRequest )
83
83
return
84
84
}
85
85
}
86
86
// Create node
87
87
node , err := store .CreateNodeUpload (u , params , files )
88
88
if err != nil {
89
- fmt . Println ("err" , err .Error ())
89
+ log . Error ("err " + err .Error ())
90
90
cx .RespondWithError (http .StatusBadRequest )
91
91
return
92
92
}
@@ -141,7 +141,6 @@ func (cr *NodeController) Read(id string, cx *goweb.Context) {
141
141
node , err := store .LoadNode (id , u .Uuid )
142
142
if err != nil {
143
143
if err .Error () == e .UnAuth {
144
- fmt .Println ("Unauthorized" )
145
144
cx .RespondWithError (http .StatusUnauthorized )
146
145
return
147
146
} else if err .Error () == e .MongoDocNotFound {
@@ -150,7 +149,7 @@ func (cr *NodeController) Read(id string, cx *goweb.Context) {
150
149
} else {
151
150
// In theory the db connection could be lost between
152
151
// checking user and load but seems unlikely.
153
- fmt . Println ("Err@node_Read:LoadNode:" , err .Error ())
152
+ log . Error ("Err@node_Read:LoadNode: " + err .Error ())
154
153
cx .RespondWithError (http .StatusInternalServerError )
155
154
return
156
155
}
@@ -176,7 +175,7 @@ func (cr *NodeController) Read(id string, cx *goweb.Context) {
176
175
r , err := os .Open (node .FilePath ())
177
176
defer r .Close ()
178
177
if err != nil {
179
- fmt . Println ("Err@node_Read:Open:" , err .Error ())
178
+ log . Error ("Err@node_Read:Open: " + err .Error ())
180
179
cx .RespondWithError (http .StatusInternalServerError )
181
180
return
182
181
}
@@ -212,22 +211,22 @@ func (cr *NodeController) Read(id string, cx *goweb.Context) {
212
211
err = s .stream ()
213
212
if err != nil {
214
213
// fix
215
- fmt . Println ("err" , err .Error ())
214
+ log . Error ("err: " + err .Error ())
216
215
}
217
216
} else {
218
217
nf , err := os .Open (node .FilePath ())
219
218
if err != nil {
220
219
// File not found or some sort of file read error.
221
220
// Probably deserves more checking
222
- fmt . Println ("err" , err .Error ())
221
+ log . Error ("err " + err .Error ())
223
222
cx .RespondWithError (http .StatusBadRequest )
224
223
return
225
224
}
226
225
s := & streamer {rs : []io.ReadCloser {nf }, ws : cx .ResponseWriter , contentType : "application/octet-stream" , filename : node .Id , size : node .File .Size , filter : fFunc }
227
226
err = s .stream ()
228
227
if err != nil {
229
228
// fix
230
- fmt . Println ("err" , err .Error ())
229
+ log . Error ("err " + err .Error ())
231
230
}
232
231
}
233
232
return
@@ -303,15 +302,15 @@ func (cr *NodeController) ReadMany(cx *goweb.Context) {
303
302
// Get nodes from db
304
303
err := nodes .GetAllLimitOffset (q , lim , off )
305
304
if err != nil {
306
- fmt . Println ("err" , err .Error ())
305
+ log . Error ("err " + err .Error ())
307
306
cx .RespondWithError (http .StatusBadRequest )
308
307
return
309
308
}
310
309
} else {
311
310
// Get nodes from db
312
311
err := nodes .GetAll (q )
313
312
if err != nil {
314
- fmt . Println ("err" , err .Error ())
313
+ log . Error ("err " + err .Error ())
315
314
cx .RespondWithError (http .StatusBadRequest )
316
315
return
317
316
}
@@ -342,7 +341,6 @@ func (cr *NodeController) Update(id string, cx *goweb.Context) {
342
341
node , err := store .LoadNode (id , u .Uuid )
343
342
if err != nil {
344
343
if err .Error () == e .UnAuth {
345
- fmt .Println ("Unauthorized" )
346
344
cx .RespondWithError (http .StatusUnauthorized )
347
345
return
348
346
} else if err .Error () == e .MongoDocNotFound {
@@ -351,7 +349,7 @@ func (cr *NodeController) Update(id string, cx *goweb.Context) {
351
349
} else {
352
350
// In theory the db connection could be lost between
353
351
// checking user and load but seems unlikely.
354
- fmt . Println ("Err@node_Update:LoadNode:" , err .Error ())
352
+ log . Error ("Err@node_Update:LoadNode: " + err .Error ())
355
353
cx .RespondWithError (http .StatusInternalServerError )
356
354
return
357
355
}
@@ -368,7 +366,7 @@ func (cr *NodeController) Update(id string, cx *goweb.Context) {
368
366
idxer := newIndexer (f )
369
367
err := idxer .Create ()
370
368
if err != nil {
371
- fmt . Println ( err .Error ())
369
+ log . Error ( "err " + err .Error ())
372
370
}
373
371
err = idxer .Dump (node .IndexPath () + "/record" )
374
372
if err != nil {
@@ -381,7 +379,7 @@ func (cr *NodeController) Update(id string, cx *goweb.Context) {
381
379
} else {
382
380
params , files , err := ParseMultipartForm (cx .Request )
383
381
if err != nil {
384
- fmt . Println ("err" , err .Error ())
382
+ log . Error ("err " + err .Error ())
385
383
cx .RespondWithError (http .StatusBadRequest )
386
384
return
387
385
}
@@ -395,7 +393,7 @@ func (cr *NodeController) Update(id string, cx *goweb.Context) {
395
393
return
396
394
}
397
395
}
398
- fmt . Println ("err" , err .Error ())
396
+ log . Error ("err " + err .Error ())
399
397
cx .RespondWithError (http .StatusBadRequest )
400
398
return
401
399
}
0 commit comments