Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Display cause of invalid config error #99

Merged
merged 3 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Matrix Static
```
go get github.com/valyala/quicktemplate/qtc
qtc
go build -o bin/ ./cmd/...
mkdir bin && go build -o bin/ ./cmd/...
```

### Docker
Expand Down
18 changes: 13 additions & 5 deletions mxclient/mxclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ package mxclient
import (
"encoding/json"
"errors"
log "github.com/Sirupsen/logrus"
"github.com/matrix-org/gomatrix"
"github.com/matrix-org/matrix-static/utils"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"time"

log "github.com/Sirupsen/logrus"
"github.com/matrix-org/gomatrix"
"github.com/matrix-org/matrix-static/utils"
)

// This is a Truncated RespInitialSync as we only need SOME information from it.
Expand Down Expand Up @@ -131,10 +133,16 @@ func NewClient(configPath string) (*Client, error) {
return nil, err
}

json.Unmarshal(file, &config)
err = json.Unmarshal(file, &config)
if err != nil {
return nil, fmt.Errorf("config file is not valid JSON: %w", err)
}

if config.HomeServer == "" {
return nil, errors.New("no user configuration found")
return nil, errors.New("no homeserver specified in config")
}
if config.AccessToken == "" {
return nil, errors.New("no accesstoken specified in config")
}

if config.MediaBaseUrl == "" {
Expand Down