File: libsasserrors.go

package info (click to toggle)
golang-github-bep-golibsass 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,840 kB
  • sloc: cpp: 30,477; ansic: 848; sh: 662; makefile: 344; perl: 124
file content (31 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright © 2022 Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

// Package libsasserrors holds the error types used by the libsass package.
package libsasserrors

import (
	"encoding/json"
	"fmt"
)

// JsonToError converts a JSON string to an error.
func JsonToError(jsonstr string) (e Error) {
	_ = json.Unmarshal([]byte(jsonstr), &e)
	return
}

// Error is a libsass error.
type Error struct {
	Status  int    `json:"status"`
	Column  int    `json:"column"`
	File    string `json:"file"`
	Line    int    `json:"line"`
	Message string `json:"message"`
}

func (e Error) Error() string {
	return fmt.Sprintf("file %q, line %d, col %d: %s ", e.File, e.Line, e.Column, e.Message)
}