fix(rest): change rest server result error type to string

This commit is contained in:
Lorenzo Delgado 2023-04-19 14:55:39 +02:00 committed by GitHub
parent e8dceb2aa6
commit d5ef9331e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import
presto
type RestServerResult*[T] = Result[T, cstring]
type RestServerResult*[T] = Result[T, string]
### Configuration
@ -84,10 +84,11 @@ proc init*(T: type RestServerRef,
maxHeadersSize = maxHeadersSize,
maxRequestBodySize = maxRequestBodySize
)
except CatchableError as ex:
return err(cstring(ex.msg))
except CatchableError:
return err(getCurrentExceptionMsg())
res
# RestResult error type is cstring, so we need to map it to string
res.mapErr(proc(err: cstring): string = $err)
proc newRestHttpServer*(ip: ValidIpAddress, port: Port,
allowedOrigin=none(string),