Skip to content

Commit 8b7708d

Browse files
committed
Error Message Polishing
This change updates the error message polishing to describe the amount of memory required by the application in order to run. [paketo-buildpacks/libjvm#4] Signed-off-by: Ben Hale <[email protected]>
1 parent 5148668 commit 8b7708d

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

calculator/calculator.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func (c Calculator) Calculate() ([]fmt.Stringer, error) {
7373
available := memory.Size(*c.TotalMemory)
7474

7575
if overhead > available {
76-
return nil, fmt.Errorf("allocated memory is greater than %s available for allocation: %s, %s, %s, %s x %d threads",
77-
available, directMemory, metaspace, reservedCodeCache, stack, *c.ThreadCount)
76+
return nil, fmt.Errorf("required memory %s is greater than %s available for allocation: %s, %s, %s, %s x %d threads",
77+
overhead, available, directMemory, metaspace, reservedCodeCache, stack, *c.ThreadCount)
7878
}
7979

8080
heap := j.MaxHeap
@@ -85,8 +85,8 @@ func (c Calculator) Calculate() ([]fmt.Stringer, error) {
8585
}
8686

8787
if overhead+memory.Size(*heap) > available {
88-
return nil, fmt.Errorf("allocated memory is greater than %s available for allocation: %s, %s, %s, %s, %s x %d threads",
89-
available, directMemory, heap, metaspace, reservedCodeCache, stack, *c.ThreadCount)
88+
return nil, fmt.Errorf("required memory %s is greater than %s available for allocation: %s, %s, %s, %s, %s x %d threads",
89+
overhead+memory.Size(*heap), available, directMemory, heap, metaspace, reservedCodeCache, stack, *c.ThreadCount)
9090
}
9191

9292
return options, nil

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
module github.com/cloudfoundry/java-buildpack-memory-calculator
22

3+
go 1.14
4+
35
require (
46
github.com/kr/pretty v0.1.0 // indirect
57
github.com/onsi/ginkgo v1.7.0 // indirect
68
github.com/onsi/gomega v1.4.3
79
github.com/sclevine/spec v1.2.0
8-
github.com/spf13/pflag v1.0.3
10+
github.com/spf13/pflag v1.0.5
911
golang.org/x/net v0.0.0-20181217023233-e147a9138326 // indirect
1012
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
1113
golang.org/x/sys v0.0.0-20181218192612-074acd46bca6 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
1616
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
1717
github.com/sclevine/spec v1.2.0 h1:1Jwdf9jSfDl9NVmt8ndHqbTZ7XCCPbh1jI3hkDBHVYA=
1818
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
19-
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
20-
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
19+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
20+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
2121
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
2222
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
2323
golang.org/x/net v0.0.0-20181217023233-e147a9138326 h1:iCzOf0xz39Tstp+Tu/WwyGjUXCk34QhQORRxBeXXTA4=

0 commit comments

Comments
 (0)